gloox  1.1-svn
mucinvite.cpp
1 /*
2  Copyright (c) 2009 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 "mucinvite.h"
16 #include "tag.h"
17 
18 #include <cstdlib>
19 
20 namespace gloox
21 {
22 
23  MUCInvite::MUCInvite( const Tag* tag )
25  {
26  if( !tag || tag->name() != "x" || tag->xmlns() != XMLNS_X_CONFERENCE )
27  return;
28 
29  m_room.setJID( tag->findAttribute( "jid" ) );
30  m_pwd = tag->findAttribute( "password" );
31  }
32 
33  MUCInvite::MUCInvite( const JID& room, const std::string& password)
34  : StanzaExtension( ExtMUCInvite ), m_room( room ), m_pwd( password )
35  {
36  }
37 
39  {
40  }
41 
42  const std::string& MUCInvite::filterString() const
43  {
44  static const std::string filter = "/message/x[@xmlns='" + XMLNS_X_CONFERENCE + "']";
45  return filter;
46  }
47 
49  {
50  if( !m_room )
51  return 0;
52 
53  Tag* t = new Tag( "x" );
55  t->addAttribute( "jid", m_room.bare() );
56  t->addAttribute( "password", m_pwd );
57 
58  return t;
59  }
60 
61 }