gloox  1.0.20
client.cpp
1 /*
2  Copyright (c) 2004-2017 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 #include "config.h"
14 
15 #include "client.h"
16 #include "capabilities.h"
17 #include "rostermanager.h"
18 #include "disco.h"
19 #include "error.h"
20 #include "logsink.h"
21 #include "nonsaslauth.h"
22 #include "prep.h"
23 #include "stanzaextensionfactory.h"
24 #include "stanzaextension.h"
25 #include "tag.h"
26 #include "tlsbase.h"
27 #include "util.h"
28 
29 #if !defined( _WIN32 ) && !defined( _WIN32_WCE )
30 # include <unistd.h>
31 #endif
32 
33 namespace gloox
34 {
35 
36  // ---- Client::ResourceBind ----
37  Client::ResourceBind::ResourceBind( const std::string& resource, bool bind )
38  : StanzaExtension( ExtResourceBind ), m_jid( JID() ), m_bind( bind )
39  {
40  prep::resourceprep( resource, m_resource );
41  m_valid = true;
42  }
43 
44  Client::ResourceBind::ResourceBind( const Tag* tag )
45  : StanzaExtension( ExtResourceBind ), m_resource( EmptyString ), m_bind( true )
46  {
47  if( !tag )
48  return;
49 
50  if( tag->name() == "unbind" )
51  m_bind = false;
52  else if( tag->name() == "bind" )
53  m_bind = true;
54  else
55  return;
56 
57  if( tag->hasChild( "jid" ) )
58  m_jid.setJID( tag->findChild( "jid" )->cdata() );
59  else if( tag->hasChild( "resource" ) )
60  m_resource = tag->findChild( "resource" )->cdata();
61 
62  m_valid = true;
63  }
64 
65  Client::ResourceBind::~ResourceBind()
66  {
67  }
68 
69  const std::string& Client::ResourceBind::filterString() const
70  {
71  static const std::string filter = "/iq/bind[@xmlns='" + XMLNS_STREAM_BIND + "']"
72  "|/iq/unbind[@xmlns='" + XMLNS_STREAM_BIND + "']";
73  return filter;
74  }
75 
76  Tag* Client::ResourceBind::tag() const
77  {
78  if( !m_valid )
79  return 0;
80 
81  Tag* t = new Tag( m_bind ? "bind" : "unbind" );
82  t->setXmlns( XMLNS_STREAM_BIND );
83 
84  if( m_bind && m_resource.empty() && m_jid )
85  new Tag( t, "jid", m_jid.full() );
86  else
87  new Tag( t, "resource", m_resource );
88 
89  return t;
90  }
91  // ---- ~Client::ResourceBind ----
92 
93  // ---- Client::SessionCreation ----
94  Tag* Client::SessionCreation::tag() const
95  {
96  Tag* t = new Tag( "session" );
97  t->setXmlns( XMLNS_STREAM_SESSION );
98  return t;
99  }
100  // ---- Client::SessionCreation ----
101 
102  // ---- Client ----
103  Client::Client( const std::string& server )
104  : ClientBase( XMLNS_CLIENT, server ),
105  m_rosterManager( 0 ), m_auth( 0 ),
106  m_presence( Presence::Available, JID() ),
107  m_forceNonSasl( false ), m_manageRoster( true ),
108  m_smId( EmptyString ), m_smLocation( EmptyString ), m_smResume( false ), m_smWanted( false ), m_smMax( 0 ),
109  m_streamFeatures( 0 )
110  {
111  m_jid.setServer( server );
112  init();
113  }
114 
115  Client::Client( const JID& jid, const std::string& password, int port )
116  : ClientBase( XMLNS_CLIENT, password, EmptyString, port ),
117  m_rosterManager( 0 ), m_auth( 0 ),
118  m_presence( Presence::Available, JID() ),
119  m_forceNonSasl( false ), m_manageRoster( true ),
120  m_smId( EmptyString ), m_smLocation( EmptyString ), m_smResume( false ), m_smWanted( false ), m_smMax( 0 ),
121  m_streamFeatures( 0 )
122  {
123  m_jid = jid;
125  init();
126  }
127 
129  {
130  delete m_rosterManager;
131  delete m_auth;
132  }
133 
134  void Client::init()
135  {
136  m_rosterManager = new RosterManager( this );
137  m_disco->setIdentity( "client", "bot" );
138  registerStanzaExtension( new ResourceBind( 0 ) );
140  m_presenceExtensions.push_back( new Capabilities( m_disco ) );
141  }
142 
143  void Client::setUsername( const std::string &username )
144  {
145  m_jid.setUsername( username );
146  }
147 
148  bool Client::handleNormalNode( Tag* tag )
149  {
150  if( tag->name() == "features" && tag->xmlns() == XMLNS_STREAM )
151  {
152  m_streamFeatures = getStreamFeatures( tag );
153 
155  && ( !m_encryption || !( m_streamFeatures & StreamFeatureStartTls ) ) )
156  {
157  logInstance().err( LogAreaClassClient, "Client is configured to require"
158  " TLS but either the server didn't offer TLS or"
159  " TLS support is not compiled in." );
161  }
163  && ( m_streamFeatures & StreamFeatureStartTls ) )
164  {
166  startTls();
167  }
169  && ( m_streamFeatures & StreamFeatureCompressZlib ) )
170  {
172  logInstance().warn( LogAreaClassClient, "The server offers compression, but negotiating Compression at this stage is not recommended. See XEP-0170 for details. We'll continue anyway." );
173  negotiateCompression( StreamFeatureCompressZlib );
174  }
175  else if( m_sasl )
176  {
177  if( m_authed )
178  {
179  if( m_streamFeatures & StreamFeatureStreamManagement && m_smWanted && m_smContext >= CtxSMEnabled )
180  {
181  sendStreamManagement();
182  }
183  else if( m_streamFeatures & StreamFeatureBind && m_smContext < CtxSMEnabled )
184  {
186  bindResource( resource() );
187  }
188  }
189  else if( !username().empty() && !password().empty() )
190  {
191  if( !login() )
192  {
193  logInstance().err( LogAreaClassClient, "The server doesn't support"
194  " any auth mechanisms we know about" );
196  }
197  }
198  else if( !m_clientCerts.empty() && !m_clientKey.empty()
199  && m_streamFeatures & SaslMechExternal && m_availableSaslMechs & SaslMechExternal )
200  {
203  }
204 #if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
205  else if( m_streamFeatures & SaslMechGssapi && m_availableSaslMechs & SaslMechGssapi )
206  {
208  startSASL( SaslMechGssapi );
209  }
210  else if( m_streamFeatures & SaslMechNTLM && m_availableSaslMechs & SaslMechNTLM )
211  {
213  startSASL( SaslMechNTLM );
214  }
215 #endif
216  else if( m_streamFeatures & SaslMechAnonymous
218  {
220  startSASL( SaslMechAnonymous );
221  }
222  else
223  {
225  connected();
226  }
227  }
229  && ( m_streamFeatures & StreamFeatureCompressZlib ) )
230  {
232  negotiateCompression( StreamFeatureCompressZlib );
233  }
234 // else if( ( m_streamFeatures & StreamFeatureCompressDclz )
235 // && m_connection->initCompression( StreamFeatureCompressDclz ) )
236 // {
237 // negotiateCompression( StreamFeatureCompressDclz );
238 // }
239  else if( m_streamFeatures & StreamFeatureIqAuth )
240  {
242  nonSaslLogin();
243  }
244  else
245  {
246  logInstance().err( LogAreaClassClient, "fallback: the server doesn't "
247  "support any auth mechanisms we know about" );
249  }
250  }
251  else
252  {
253  const std::string& name = tag->name(),
254  xmlns = tag->findAttribute( XMLNS );
255  if( name == "proceed" && xmlns == XMLNS_STREAM_TLS )
256  {
257  logInstance().dbg( LogAreaClassClient, "starting TLS handshake..." );
258 
259  if( m_encryption )
260  {
261  m_encryptionActive = true;
263  }
264  }
265  else if( name == "failure" )
266  {
267  if( xmlns == XMLNS_STREAM_TLS )
268  {
269  logInstance().err( LogAreaClassClient, "TLS handshake failed (server-side)!" );
271  }
272  else if( xmlns == XMLNS_COMPRESSION )
273  {
274  logInstance().err( LogAreaClassClient, "Stream compression init failed!" );
276  }
277  else if( xmlns == XMLNS_STREAM_SASL )
278  {
279  logInstance().err( LogAreaClassClient, "SASL authentication failed!" );
280  processSASLError( tag );
282  }
283  }
284  else if( name == "compressed" && xmlns == XMLNS_COMPRESSION )
285  {
286  logInstance().dbg( LogAreaClassClient, "Stream compression initialized" );
287  m_compressionActive = true;
288  header();
289  }
290  else if( name == "challenge" && xmlns == XMLNS_STREAM_SASL )
291  {
292  logInstance().dbg( LogAreaClassClient, "Processing SASL challenge" );
293  processSASLChallenge( tag->cdata() );
294  }
295  else if( name == "success" && xmlns == XMLNS_STREAM_SASL )
296  {
297  if( !processSASLSuccess( tag->cdata() ) )
298  {
299  logInstance().err( LogAreaClassClient, "The Server response could not be verified!" );
301  return false;
302  }
303 
304  logInstance().dbg( LogAreaClassClient, "SASL authentication successful" );
305  setAuthed( true );
306  header();
307  }
308  else if( name == "enabled" && xmlns == XMLNS_STREAM_MANAGEMENT )
309  {
311  m_smMax = atoi( tag->findAttribute( "max" ).c_str() );
312  m_smId = tag->findAttribute( "id" );
313  const std::string res = tag->findAttribute( "resume" );
314  m_smResume = ( ( res == "true" || res == "1" ) && !m_smId.empty() ) ? true : false;
315  m_smLocation = tag->findAttribute( "location" );
316 
317  if( m_streamFeatures & StreamFeatureSession )
318  createSession();
319  else
320  connected();
321  }
322  else if( name == "resumed" && xmlns == XMLNS_STREAM_MANAGEMENT && m_smContext == CtxSMResume )
323  {
324  if( tag->findAttribute( "previd" ) == m_smId )
325  {
328  int h = atoi( tag->findAttribute( "h" ).c_str() );
329  connected();
330  checkQueue( h, true );
331  }
332  }
333  else if( name == "a" && xmlns == XMLNS_STREAM_MANAGEMENT && m_smContext >= CtxSMEnabled )
334  {
335  int h = atoi( tag->findAttribute( "h" ).c_str() );
336  checkQueue( h, false );
337  }
338  else if( name == "r" && xmlns == XMLNS_STREAM_MANAGEMENT )
339  {
341  }
342  else if( name == "failed" && xmlns == XMLNS_STREAM_MANAGEMENT )
343  {
344  switch( m_smContext )
345  {
346  case CtxSMEnable:
348  break;
349  case CtxSMResume:
351  break;
352  default:
353  break;
354  }
356  }
357  else
358  return false;
359  }
360 
361  return true;
362  }
363 
364  int Client::getStreamFeatures( Tag* tag )
365  {
366  if( tag->name() != "features" || tag->xmlns() != XMLNS_STREAM )
367  return 0;
368 
369  int features = 0;
370 
371  if( tag->hasChild( "starttls", XMLNS, XMLNS_STREAM_TLS ) )
372  features |= StreamFeatureStartTls;
373 
374  if( tag->hasChild( "mechanisms", XMLNS, XMLNS_STREAM_SASL ) )
375  features |= getSaslMechs( tag->findChild( "mechanisms" ) );
376 
377  if( tag->hasChild( "bind", XMLNS, XMLNS_STREAM_BIND ) )
378  features |= StreamFeatureBind;
379 
380  if( tag->hasChild( "unbind", XMLNS, XMLNS_STREAM_BIND ) )
381  features |= StreamFeatureUnbind;
382 
383  if( tag->hasChild( "session", XMLNS, XMLNS_STREAM_SESSION ) )
384  features |= StreamFeatureSession;
385 
386  if( tag->hasChild( "auth", XMLNS, XMLNS_STREAM_IQAUTH ) )
387  features |= StreamFeatureIqAuth;
388 
389  if( tag->hasChild( "register", XMLNS, XMLNS_STREAM_IQREGISTER ) )
390  features |= StreamFeatureIqRegister;
391 
392  if( tag->hasChild( "compression", XMLNS, XMLNS_STREAM_COMPRESS ) )
393  features |= getCompressionMethods( tag->findChild( "compression" ) );
394 
395  if( tag->hasChild( "sm", XMLNS, XMLNS_STREAM_MANAGEMENT ) )
396  features |= StreamFeatureStreamManagement;
397 
398  if( tag->hasChild( "csi", XMLNS, XMLNS_CLIENT_STATE_INDICATION ) )
400 
401  if( features == 0 )
402  features = StreamFeatureIqAuth;
403 
404  return features;
405  }
406 
407  int Client::getSaslMechs( Tag* tag )
408  {
409  int mechs = SaslMechNone;
410 
411  const std::string mech = "mechanism";
412 
413  if( tag->hasChildWithCData( mech, "SCRAM-SHA-1-PLUS" ) )
414  mechs |= SaslMechScramSha1Plus;
415 
416  if( tag->hasChildWithCData( mech, "SCRAM-SHA-1" ) )
417  mechs |= SaslMechScramSha1;
418 
419  if( tag->hasChildWithCData( mech, "DIGEST-MD5" ) )
420  mechs |= SaslMechDigestMd5;
421 
422  if( tag->hasChildWithCData( mech, "PLAIN" ) )
423  mechs |= SaslMechPlain;
424 
425  if( tag->hasChildWithCData( mech, "ANONYMOUS" ) )
426  mechs |= SaslMechAnonymous;
427 
428  if( tag->hasChildWithCData( mech, "EXTERNAL" ) )
429  mechs |= SaslMechExternal;
430 
431  if( tag->hasChildWithCData( mech, "GSSAPI" ) )
432  mechs |= SaslMechGssapi;
433 
434  if( tag->hasChildWithCData( mech, "NTLM" ) )
435  mechs |= SaslMechNTLM;
436 
437  return mechs;
438  }
439 
440  int Client::getCompressionMethods( Tag* tag )
441  {
442  int meths = 0;
443 
444  if( tag->hasChildWithCData( "method", "zlib" ) )
445  meths |= StreamFeatureCompressZlib;
446 
447  if( tag->hasChildWithCData( "method", "lzw" ) )
448  meths |= StreamFeatureCompressDclz;
449 
450  return meths;
451  }
452 
454  {
455  bool retval = true;
456 
459  && !m_forceNonSasl )
460  {
463  }
464  else if( m_streamFeatures & SaslMechScramSha1 && m_availableSaslMechs & SaslMechScramSha1
465  && !m_forceNonSasl )
466  {
469  }
470  else if( m_streamFeatures & SaslMechDigestMd5 && m_availableSaslMechs & SaslMechDigestMd5
471  && !m_forceNonSasl )
472  {
475  }
476  else if( m_streamFeatures & SaslMechPlain && m_availableSaslMechs & SaslMechPlain
477  && !m_forceNonSasl )
478  {
481  }
482  else if( m_streamFeatures & StreamFeatureIqAuth || m_forceNonSasl )
483  {
485  nonSaslLogin();
486  }
487  else
488  retval = false;
489 
490  return retval;
491  }
492 
493  void Client::handleIqIDForward( const IQ& iq, int context )
494  {
495  switch( context )
496  {
497  case CtxResourceUnbind:
498  // we don't store known resources anyway
499  break;
500  case CtxResourceBind:
501  processResourceBind( iq );
502  break;
503  case CtxSessionEstablishment:
504  processCreateSession( iq );
505  break;
506  default:
507  break;
508  }
509  }
510 
511  bool Client::bindOperation( const std::string& resource, bool bind )
512  {
513  if( !( m_streamFeatures & StreamFeatureUnbind ) && m_resourceBound )
514  return false;
515 
516  IQ iq( IQ::Set, JID(), getID() );
517  iq.addExtension( new ResourceBind( resource, bind ) );
518 
519  send( iq, this, bind ? CtxResourceBind : CtxResourceUnbind );
520  return true;
521  }
522 
523  bool Client::selectResource( const std::string& resource )
524  {
525  m_selectedResource = resource; // TODO: remove for 1.1
526  m_jid.setResource( resource );
527 
528  if( !( m_streamFeatures & StreamFeatureUnbind ) )
529  return false;
530 
531  return true;
532  }
533 
534  void Client::processResourceBind( const IQ& iq )
535  {
536  switch( iq.subtype() )
537  {
538  case IQ::Result:
539  {
540  const ResourceBind* rb = iq.findExtension<ResourceBind>( ExtResourceBind );
541  if( !rb || !rb->jid() )
542  {
544  break;
545  }
546 
547  m_jid = rb->jid();
548  m_resourceBound = true;
549  m_selectedResource = m_jid.resource(); // TODO: remove for 1.1
551 
552  if( m_streamFeatures & StreamFeatureStreamManagement && m_smWanted )
553  sendStreamManagement();
554  else if( m_streamFeatures & StreamFeatureSession )
555  createSession();
556  else
557  connected();
558  break;
559  }
560  case IQ::Error:
561  {
563  break;
564  }
565  default:
566  break;
567  }
568  }
569 
570  void Client::setStreamManagement( bool enable, bool resume )
571  {
572  m_smWanted = enable;
573  m_smResume = resume;
574 
575  if( !m_smWanted )
576  {
577  m_smId = EmptyString;
578  m_smLocation = EmptyString;
579  m_smMax = 0;
580  m_smResume = false;
581  return;
582  }
583 
584  if( m_smWanted && m_resourceBound )
585  sendStreamManagement();
586  }
587 
588  void Client::sendStreamManagement()
589  {
590  if( !m_smWanted )
591  return;
592 
593  if( m_smContext == CtxSMInvalid )
594  {
596  Tag* e = new Tag( "enable" );
598  if( m_smResume )
599  e->addAttribute( "resume", "true" );
600  send( e );
602  m_smHandled = 0;
603  }
604  else if( m_smContext == CtxSMEnabled )
605  {
607  Tag* r = new Tag( "resume" );
609  r->addAttribute( "h", m_smHandled );
610  r->addAttribute( "previd", m_smId );
611  send( r );
613  }
614  }
615 
617  {
618  if( m_smContext >= CtxSMEnabled )
619  {
620  Tag* a = new Tag( "a", "xmlns", XMLNS_STREAM_MANAGEMENT );
621  a->addAttribute( "h", m_smHandled );
622  send( a );
623  }
624  }
625 
627  {
628  if( m_smContext >= CtxSMEnabled )
629  {
630  Tag* r = new Tag( "r", "xmlns", XMLNS_STREAM_MANAGEMENT );
631  send( r );
632  }
633  }
634 
635  void Client::createSession()
636  {
638  IQ iq( IQ::Set, JID(), getID() );
639  iq.addExtension( new SessionCreation() );
640  send( iq, this, CtxSessionEstablishment );
641  }
642 
643  void Client::processCreateSession( const IQ& iq )
644  {
645  switch( iq.subtype() )
646  {
647  case IQ::Result:
648  connected();
649  break;
650  case IQ::Error:
652  break;
653  default:
654  break;
655  }
656  }
657 
658  void Client::negotiateCompression( StreamFeature method )
659  {
660  Tag* t = new Tag( "compress", XMLNS, XMLNS_COMPRESSION );
661 
662  if( method == StreamFeatureCompressZlib )
663  new Tag( t, "method", "zlib" );
664 
665  if( method == StreamFeatureCompressDclz )
666  new Tag( t, "method", "lzw" );
667 
668  send( t );
669  }
670 
672  const std::string& status )
673  {
674  m_presence.setPresence( pres );
675  m_presence.setPriority( priority );
676  m_presence.resetStatus();
677  m_presence.addStatus( status );
678  sendPresence( m_presence );
679  }
680 
682  const std::string& status )
683  {
684  Presence p( pres, to, status, priority );
685  sendPresence( p );
686  }
687 
688  void Client::sendPresence( Presence& pres )
689  {
690  if( state() < StateConnected )
691  return;
692 
693  send( pres );
694  }
695 
697  {
698  m_manageRoster = false;
699  delete m_rosterManager;
700  m_rosterManager = 0;
701  }
702 
704  {
705  if( !m_auth )
706  m_auth = new NonSaslAuth( this );
707  m_auth->doAuth( m_sid );
708  }
709 
710  void Client::connected()
711  {
712  if( m_authed && m_smContext != CtxSMResumed )
713  {
714  if( m_manageRoster )
715  {
717  m_rosterManager->fill();
718  }
719  else
720  rosterFilled();
721  }
722  else
723  {
725  notifyOnConnect();
726  }
727  }
728 
729  void Client::rosterFilled()
730  {
731  sendPresence( m_presence );
733  notifyOnConnect();
734  }
735 
737  {
739  m_smHandled = 0;
740  m_smId = EmptyString;
741  m_smLocation = EmptyString;
742  m_smMax = 0;
743  m_smResume = false;
744  m_smWanted = false;
745 
747  }
748 
749  void Client::disconnect( ConnectionError reason )
750  {
751  m_resourceBound = false;
752  m_authed = false;
753  m_streamFeatures = 0;
754  ClientBase::disconnect( reason );
755  }
756 
757  void Client::cleanup()
758  {
759  m_authed = false;
760  m_resourceBound = false;
761  m_streamFeatures = 0;
762  }
763 
764 }
TLSBase * m_encryption
Definition: clientbase.h:872
void processSASLChallenge(const std::string &challenge)
Definition: clientbase.cpp:707
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
Definition: tag.cpp:522
bool setServer(const std::string &server)
Definition: jid.cpp:56
bool setResource(const std::string &resource)
Definition: jid.cpp:64
const std::string XMLNS_COMPRESSION
Definition: gloox.cpp:27
const StanzaExtension * findExtension(int type) const
Definition: stanza.cpp:57
const std::string XMLNS_STREAM_TLS
Definition: gloox.cpp:87
void dbg(LogArea area, const std::string &message) const
Definition: logsink.h:66
const std::string XMLNS_STREAM_MANAGEMENT
Definition: gloox.cpp:109
const std::string XMLNS_STREAM_IQAUTH
Definition: gloox.cpp:92
void doAuth(const std::string &sid)
const std::string XMLNS
Definition: gloox.cpp:122
const std::string XMLNS_STREAM_SASL
Definition: gloox.cpp:89
const std::string xmlns() const
Definition: tag.cpp:543
const std::string & serverRaw() const
Definition: jid.h:110
An abstraction of an IQ stanza.
Definition: iq.h:33
void addStatus(const std::string &status, const std::string &lang=EmptyString)
Definition: presence.h:117
void addExtension(const StanzaExtension *se)
Definition: stanza.cpp:52
LogSink & logInstance()
Definition: clientbase.h:599
void send(Tag *tag)
void disableRoster()
Definition: client.cpp:696
bool hasChildWithCData(const std::string &name, const std::string &cdata) const
Definition: tag.cpp:647
void setUsername(const std::string &username)
Definition: client.cpp:143
void notifyOnResourceBind(const std::string &resource)
const std::string XMLNS_CLIENT
Definition: gloox.cpp:19
const std::string & resource() const
Definition: client.h:200
void registerStanzaExtension(StanzaExtension *ext)
int priority() const
Definition: client.h:239
std::string m_server
Definition: clientbase.h:888
This class is an implementation of XEP-0078 (Non-SASL Authentication).
Definition: nonsaslauth.h:39
ConnectionError
Definition: gloox.h:683
IqType subtype() const
Definition: iq.h:74
Client(const std::string &server)
Definition: client.cpp:103
const std::string & name() const
Definition: tag.h:394
const std::string XMLNS_CLIENT_STATE_INDICATION
Definition: gloox.cpp:115
void notifyOnResourceBindError(const Error *error)
std::string m_clientKey
Definition: clientbase.h:884
bool hasChild(const std::string &name, const std::string &attr=EmptyString, const std::string &value=EmptyString) const
Definition: tag.cpp:615
virtual ~Client()
Definition: client.cpp:128
GLOOX_DEPRECATED std::string m_selectedResource
Definition: clientbase.h:879
void reqStreamManagement()
Definition: client.cpp:626
Tag * findChild(const std::string &name) const
Definition: tag.cpp:624
void warn(LogArea area, const std::string &message) const
Definition: logsink.h:75
bool bindResource(const std::string &resource)
Definition: client.h:163
An abstraction of a presence stanza.
Definition: presence.h:32
bool login()
Definition: client.cpp:453
virtual bool hasChannelBinding() const
Definition: tlsbase.h:111
void setStreamManagement(bool enable=true, bool resume=true)
Definition: client.cpp:570
const JID & jid()
Definition: clientbase.h:147
const std::string XMLNS_STREAM_SESSION
Definition: gloox.cpp:91
virtual const std::string & password() const
Definition: clientbase.h:227
bool processSASLSuccess(const std::string &payload)
Definition: clientbase.cpp:927
ConnectionState state() const
void setPriority(int priority)
Definition: presence.cpp:93
void nonSaslLogin()
Definition: client.cpp:703
The namespace for the gloox library.
Definition: adhoc.cpp:27
TLSPolicy m_tls
Definition: clientbase.h:901
bool setUsername(const std::string &username)
Definition: jid.cpp:49
StanzaExtensionList m_presenceExtensions
Definition: clientbase.h:877
void notifyOnSessionCreateError(const Error *error)
void resetStatus()
Definition: presence.cpp:86
const Error * error() const
Definition: stanza.cpp:47
void setPresence(PresenceType type)
Definition: presence.h:95
CompressionBase * m_compression
Definition: clientbase.h:873
This class implements Jabber/XMPP roster handling in the jabber:iq:roster namespace.
Definition: rostermanager.h:47
std::string m_sid
Definition: clientbase.h:890
const std::string XMLNS_STREAM_COMPRESS
Definition: gloox.cpp:95
virtual void disconnect(ConnectionError reason)
Definition: clientbase.cpp:404
void setIdentity(const std::string &category, const std::string &type, const std::string &name=EmptyString)
Definition: disco.cpp:474
const std::string XMLNS_STREAM
Definition: gloox.cpp:84
An abstraction of a JID.
Definition: jid.h:30
StreamFeature
Definition: gloox.h:733
bool addAttribute(Attribute *attr)
Definition: tag.cpp:354
virtual bool handshake()=0
const std::string & resource() const
Definition: jid.h:116
bool resourceprep(const std::string &resource, std::string &out)
Definition: prep.cpp:83
void processSASLError(Tag *tag)
Definition: clientbase.cpp:899
std::string m_clientCerts
Definition: clientbase.h:883
bool m_compressionActive
Definition: clientbase.h:891
SMContext m_smContext
Definition: clientbase.h:920
const std::string getID()
const std::string & findAttribute(const std::string &name) const
Definition: tag.cpp:589
This is an implementation of XEP-0115 (Entity Capabilities).
Definition: capabilities.h:36
const std::string cdata() const
Definition: tag.cpp:497
void ackStreamManagement()
Definition: client.cpp:616
void notifyStreamEvent(StreamEvent event)
void setPresence()
Definition: client.h:293
void checkQueue(int handled, bool resend)
void setAuthed(bool authed)
Definition: clientbase.h:777
const std::string XMLNS_STREAM_IQREGISTER
Definition: gloox.cpp:93
virtual const std::string & username() const
Definition: clientbase.h:138
void startSASL(SaslMechanism type)
Definition: clientbase.cpp:485
const std::string XMLNS_STREAM_BIND
Definition: gloox.cpp:90
int port() const
Definition: clientbase.h:221
void err(LogArea area, const std::string &message) const
Definition: logsink.h:84
const std::string EmptyString
Definition: gloox.cpp:124
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition: clientbase.h:76
This is an abstraction of an XML element.
Definition: tag.h:46
bool selectResource(const std::string &resource)
Definition: client.cpp:523
void disconnect()
Definition: client.cpp:736