gloox
0.9.9.12
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
uniquemucroom.cpp
1
/*
2
Copyright (c) 2007-2008 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 "uniquemucroom.h"
16
#include "clientbase.h"
17
#include "jid.h"
18
#include "sha.h"
19
20
namespace
gloox
21
{
22
23
UniqueMUCRoom::UniqueMUCRoom
(
ClientBase
*parent,
const
JID
& nick,
MUCRoomHandler
*mrh )
24
:
InstantMUCRoom
( parent, nick, mrh )
25
{
26
}
27
28
UniqueMUCRoom::~UniqueMUCRoom
()
29
{
30
m_parent->
removeIDHandler
(
this
);
31
}
32
33
void
UniqueMUCRoom::join
()
34
{
35
if
( !m_parent || m_joined )
36
return
;
37
38
const
std::string&
id
= m_parent->
getID
();
39
Tag
*iq =
new
Tag
(
"iq"
);
40
iq->
addAttribute
(
"id"
,
id
);
41
iq->
addAttribute
(
"to"
, m_nick.
server
() );
42
iq->
addAttribute
(
"type"
,
"get"
);
43
Tag
*u =
new
Tag
( iq,
"unique"
);
44
u->
addAttribute
(
"xmlns"
,
XMLNS_MUC_UNIQUE
);
45
46
m_parent->
trackID
(
this
,
id
,
RequestUniqueName
);
47
m_parent->
send
( iq );
48
}
49
50
bool
UniqueMUCRoom::handleIqID(
Stanza
*stanza,
int
context )
51
{
52
switch
( stanza->
subtype
() )
53
{
54
case
StanzaIqResult
:
55
if
( context ==
RequestUniqueName
)
56
{
57
Tag
*u = stanza->
findChild
(
"unique"
,
"xmlns"
,
XMLNS_MUC_UNIQUE
);
58
if
( u )
59
{
60
const
std::string&
name
= u->
cdata
();
61
if
( !name.empty() )
62
setName( name );
63
}
64
}
65
break
;
66
case
StanzaIqError
:
67
if
( context ==
RequestUniqueName
)
68
{
69
SHA s;
70
s.feed( m_parent->
jid
().
full
() );
71
s.feed( m_parent->
getID
() );
72
setName( s.hex() );
73
}
74
break
;
75
default
:
76
break
;
77
}
78
79
MUCRoom::join
();
80
81
return
false
;
82
}
83
84
}
Generated on Thu Jun 27 2013 13:05:48 for gloox by
1.8.1.2