gloox
1.0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
component.cpp
1
/*
2
Copyright (c) 2005-2012 by Jakob Schroeter <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
14
15
#include "component.h"
16
17
#include "disco.h"
18
#include "stanza.h"
19
#include "prep.h"
20
#include "sha.h"
21
22
#include <cstdlib>
23
24
namespace
gloox
25
{
26
27
Component::Component
(
const
std::string& ns,
const
std::string& server,
28
const
std::string& component,
const
std::string& password,
int
port )
29
:
ClientBase
( ns, password, server, port )
30
{
31
m_jid
.
setServer
( component );
32
m_disco
->
setIdentity
(
"component"
,
"generic"
);
33
}
34
35
void
Component::handleStartNode
(
const
Tag
*
/*start*/
)
36
{
37
if
(
m_sid
.empty() )
38
return
;
39
40
notifyStreamEvent
(
StreamEventAuthentication
);
41
42
SHA
sha;
43
sha.
feed
(
m_sid
+
m_password
);
44
sha.
finalize
();
45
46
Tag
* h =
new
Tag
(
"handshake"
, sha.
hex
() );
47
send
( h );
48
}
49
50
bool
Component::handleNormalNode
(
Tag
* tag )
51
{
52
if
( tag->
name
() !=
"handshake"
)
53
return
false
;
54
55
m_authed
=
true
;
56
notifyStreamEvent
(
StreamEventFinished
);
57
notifyOnConnect
();
58
59
return
true
;
60
}
61
62
}
Generated on Sun Jun 30 2013 14:37:36 for gloox by
1.8.1.2