Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: third_party/libjingle_xmpp/xmpp/xmppclient.h

Issue 2443903004: Add xmllite and xmpp sources to third_party/ (Closed)
Patch Set: Fix GN and sort includes Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2004 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WEBRTC_LIBJINGLE_XMPP_XMPPCLIENT_H_
6 #define WEBRTC_LIBJINGLE_XMPP_XMPPCLIENT_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "third_party/libjingle_xmpp/xmpp/asyncsocket.h"
12 #include "third_party/libjingle_xmpp/xmpp/xmppclientsettings.h"
13 #include "third_party/libjingle_xmpp/xmpp/xmppengine.h"
14 #include "third_party/libjingle_xmpp/xmpp/xmpptask.h"
15 #include "webrtc/base/sigslot.h"
16 #include "webrtc/base/task.h"
17
18 namespace buzz {
19
20 class PreXmppAuth;
21 class CaptchaChallenge;
22
23 // Just some non-colliding number. Could have picked "1".
24 #define XMPP_CLIENT_TASK_CODE 0x366c1e47
25
26 /////////////////////////////////////////////////////////////////////
27 //
28 // XMPPCLIENT
29 //
30 /////////////////////////////////////////////////////////////////////
31 //
32 // See Task first. XmppClient is a parent task for XmppTasks.
33 //
34 // XmppClient is a task which is designed to be the parent task for
35 // all tasks that depend on a single Xmpp connection. If you want to,
36 // for example, listen for subscription requests forever, then your
37 // listener should be a task that is a child of the XmppClient that owns
38 // the connection you are using. XmppClient has all the utility methods
39 // that basically drill through to XmppEngine.
40 //
41 // XmppClient is just a wrapper for XmppEngine, and if I were writing it
42 // all over again, I would make XmppClient == XmppEngine. Why?
43 // XmppEngine needs tasks too, for example it has an XmppLoginTask which
44 // should just be the same kind of Task instead of an XmppEngine specific
45 // thing. It would help do certain things like GAIA auth cleaner.
46 //
47 /////////////////////////////////////////////////////////////////////
48
49 class XmppClient : public XmppTaskParentInterface,
50 public XmppClientInterface,
51 public sigslot::has_slots<>
52 {
53 public:
54 explicit XmppClient(rtc::TaskParent * parent);
55 virtual ~XmppClient();
56
57 XmppReturnStatus Connect(const XmppClientSettings & settings,
58 const std::string & lang,
59 AsyncSocket * socket,
60 PreXmppAuth * preauth);
61
62 virtual int ProcessStart();
63 virtual int ProcessResponse();
64 XmppReturnStatus Disconnect();
65
66 sigslot::signal1<XmppEngine::State> SignalStateChange;
67 XmppEngine::Error GetError(int *subcode);
68
69 // When there is a <stream:error> stanza, return the stanza
70 // so that they can be handled.
71 const XmlElement *GetStreamError();
72
73 // When there is an authentication error, we may have captcha info
74 // that the user can use to unlock their account
75 CaptchaChallenge GetCaptchaChallenge();
76
77 // When authentication is successful, this returns the service token
78 // (if we used GAIA authentication)
79 std::string GetAuthMechanism();
80 std::string GetAuthToken();
81
82 XmppReturnStatus SendRaw(const std::string & text);
83
84 XmppEngine* engine();
85
86 sigslot::signal2<const char *, int> SignalLogInput;
87 sigslot::signal2<const char *, int> SignalLogOutput;
88
89 // As XmppTaskParentIntreface
90 virtual XmppClientInterface* GetClient() { return this; }
91
92 // As XmppClientInterface
93 virtual XmppEngine::State GetState() const;
94 virtual const Jid& jid() const;
95 virtual std::string NextId();
96 virtual XmppReturnStatus SendStanza(const XmlElement *stanza);
97 virtual XmppReturnStatus SendStanzaError(const XmlElement * pelOriginal,
98 XmppStanzaError code,
99 const std::string & text);
100 virtual void AddXmppTask(XmppTask *, XmppEngine::HandlerLevel);
101 virtual void RemoveXmppTask(XmppTask *);
102
103 private:
104 friend class XmppTask;
105
106 void OnAuthDone();
107
108 // Internal state management
109 enum {
110 STATE_PRE_XMPP_LOGIN = STATE_NEXT,
111 STATE_START_XMPP_LOGIN = STATE_NEXT + 1,
112 };
113 int Process(int state) {
114 switch (state) {
115 case STATE_PRE_XMPP_LOGIN: return ProcessTokenLogin();
116 case STATE_START_XMPP_LOGIN: return ProcessStartXmppLogin();
117 default: return Task::Process(state);
118 }
119 }
120
121 std::string GetStateName(int state) const {
122 switch (state) {
123 case STATE_PRE_XMPP_LOGIN: return "PRE_XMPP_LOGIN";
124 case STATE_START_XMPP_LOGIN: return "START_XMPP_LOGIN";
125 default: return Task::GetStateName(state);
126 }
127 }
128
129 int ProcessTokenLogin();
130 int ProcessStartXmppLogin();
131 void EnsureClosed();
132
133 class Private;
134 friend class Private;
135 std::unique_ptr<Private> d_;
136
137 bool delivering_signal_;
138 bool valid_;
139 };
140
141 }
142
143 #endif // WEBRTC_LIBJINGLE_XMPP_XMPPCLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698