• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2004 The WebRTC Project Authors. All rights reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef WEBRTC_LIBJINGLE_XMPP_LOGINTASK_H_
12 #define WEBRTC_LIBJINGLE_XMPP_LOGINTASK_H_
13 
14 #include <string>
15 #include <vector>
16 
17 #include "webrtc/libjingle/xmpp/jid.h"
18 #include "webrtc/libjingle/xmpp/xmppengine.h"
19 #include "webrtc/base/logging.h"
20 #include "webrtc/base/scoped_ptr.h"
21 
22 namespace buzz {
23 
24 class XmlElement;
25 class XmppEngineImpl;
26 class SaslMechanism;
27 
28 
29 // TODO: Rename to LoginTask.
30 class XmppLoginTask {
31 
32 public:
33   XmppLoginTask(XmppEngineImpl *pctx);
34   ~XmppLoginTask();
35 
IsDone()36   bool IsDone()
37     { return state_ == LOGINSTATE_DONE; }
38   void IncomingStanza(const XmlElement * element, bool isStart);
39   void OutgoingStanza(const XmlElement *element);
set_allow_non_google_login(bool b)40   void set_allow_non_google_login(bool b)
41     { allowNonGoogleLogin_ = b; }
42 
43 private:
44   enum LoginTaskState {
45     LOGINSTATE_INIT = 0,
46     LOGINSTATE_STREAMSTART_SENT,
47     LOGINSTATE_STARTED_XMPP,
48     LOGINSTATE_TLS_INIT,
49     LOGINSTATE_AUTH_INIT,
50     LOGINSTATE_BIND_INIT,
51     LOGINSTATE_TLS_REQUESTED,
52     LOGINSTATE_SASL_RUNNING,
53     LOGINSTATE_BIND_REQUESTED,
54     LOGINSTATE_SESSION_REQUESTED,
55     LOGINSTATE_DONE,
56   };
57 
58   const XmlElement * NextStanza();
59   bool Advance();
60   bool HandleStartStream(const XmlElement * element);
61   bool HandleFeatures(const XmlElement * element);
62   const XmlElement * GetFeature(const QName & name);
63   bool Failure(XmppEngine::Error reason);
64   void FlushQueuedStanzas();
65 
66   XmppEngineImpl * pctx_;
67   bool authNeeded_;
68   bool allowNonGoogleLogin_;
69   LoginTaskState state_;
70   const XmlElement * pelStanza_;
71   bool isStart_;
72   std::string iqId_;
73   rtc::scoped_ptr<XmlElement> pelFeatures_;
74   Jid fullJid_;
75   std::string streamId_;
76   rtc::scoped_ptr<std::vector<XmlElement *> > pvecQueuedStanzas_;
77 
78   rtc::scoped_ptr<SaslMechanism> sasl_mech_;
79 
80 #if !defined(NDEBUG)
81   static const rtc::ConstantLabel LOGINTASK_STATES[];
82 #endif
83 };
84 
85 }
86 
87 #endif  //  WEBRTC_LIBJINGLE_XMPP_LOGINTASK_H_
88