glooxd  0.3-svn
discomanager.cpp
1 /*
2  Copyright (c) 2009 by Jakob Schroeter <js@camaya.net>
3  This file is part of the glooxd library. http://camaya.net/glooxd
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 #include "sm.h"
15 #include "taghandler.h"
16 #include "discomanager.h"
17 
18 #include <gloox/gloox.h>
19 #include <gloox/iq.h>
20 #include <gloox/tag.h>
21 #include <gloox/disco.h>
22 
23 #include <cstdio>
24 
25 namespace glooxd
26 {
27 
29  : Plugin( sm, router )
30  {
31  }
32 
34  {
35  }
36 
37  const std::string& DiscoManager::filterString() const
38  {
39  static const std::string filter = "/iq[/iq/query[@xmlns='" + gloox::XMLNS_DISCO_INFO + "']]"
40  "|/iq[/iq/query[@xmlns='" + gloox::XMLNS_DISCO_ITEMS + "']]";
41  return filter;
42  }
43 
44  bool DiscoManager::handleTag( const gloox::Tag* tag )
45  {
46  if( !tag )
47  return false;
48 
49  // printf( "received a disco tag!!!!!!!!!! %s\n", tag->xml().c_str() );
50 
51  gloox::IQ re( gloox::IQ::Result, tag->findAttribute( "from" ),
52  tag->findAttribute( "id" ) );
53  re.setFrom( tag->findAttribute( "to" ) );
54  m_router.handleIncomingTag( re.tag() );
55 
56  return true;
57  }
58 
59 }