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

Side by Side Diff: webrtc/libjingle/xmpp/moduleimpl.h

Issue 2617443003: Remove webrtc/libjingle/{xmllite,xmpp} (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « webrtc/libjingle/xmpp/module.h ('k') | webrtc/libjingle/xmpp/moduleimpl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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_MODULEIMPL_H_
12 #define WEBRTC_LIBJINGLE_XMPP_MODULEIMPL_H_
13
14 #include "webrtc/libjingle/xmpp/module.h"
15 #include "webrtc/libjingle/xmpp/xmppengine.h"
16
17 namespace buzz {
18
19 //! This is the base implementation class for extension modules.
20 //! An engine is registered with the module and the module then hooks the
21 //! appropriate parts of the engine to implement that set of features. It is
22 //! important to unregister modules before destructing the engine.
23 class XmppModuleImpl {
24 protected:
25 XmppModuleImpl();
26 virtual ~XmppModuleImpl();
27
28 //! Register the engine with the module. Only one engine can be associated
29 //! with a module at a time. This method will return an error if there is
30 //! already an engine registered.
31 XmppReturnStatus RegisterEngine(XmppEngine* engine);
32
33 //! Gets the engine that this module is attached to.
34 XmppEngine* engine();
35
36 //! Process the given stanza.
37 //! The module must return true if it has handled the stanza.
38 //! A false return value causes the stanza to be passed on to
39 //! the next registered handler.
40 virtual bool HandleStanza(const XmlElement *) { return false; };
41
42 private:
43
44 //! The ModuleSessionHelper nested class allows the Module
45 //! to hook into and get stanzas and events from the engine.
46 class ModuleStanzaHandler : public XmppStanzaHandler {
47 friend class XmppModuleImpl;
48
49 ModuleStanzaHandler(XmppModuleImpl* module) :
50 module_(module) {
51 }
52
53 bool HandleStanza(const XmlElement* stanza) {
54 return module_->HandleStanza(stanza);
55 }
56
57 XmppModuleImpl* module_;
58 };
59
60 friend class ModuleStanzaHandler;
61
62 XmppEngine* engine_;
63 ModuleStanzaHandler stanza_handler_;
64 };
65
66
67 // This macro will implement the XmppModule interface for a class
68 // that derives from both XmppModuleImpl and XmppModule
69 #define IMPLEMENT_XMPPMODULE \
70 XmppReturnStatus RegisterEngine(XmppEngine* engine) { \
71 return XmppModuleImpl::RegisterEngine(engine); \
72 }
73
74 }
75
76 #endif // WEBRTC_LIBJINGLE_XMPP_MODULEIMPL_H_
OLDNEW
« no previous file with comments | « webrtc/libjingle/xmpp/module.h ('k') | webrtc/libjingle/xmpp/moduleimpl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698