glooxd  0.3-svn
vcardmanager.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 "vcardmanager.h"
17 
18 #include <gloox/gloox.h>
19 #include <gloox/iq.h>
20 #include <gloox/tag.h>
21 #include <gloox/vcard.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& VCardManager::filterString() const
38  {
39  static const std::string filter = "/iq[/iq/vCard[@xmlns='" + gloox::XMLNS_VCARD_TEMP + "']]";
40  return filter;
41  }
42 
43  bool VCardManager::handleTag( const gloox::Tag* tag )
44  {
45  if( !tag )
46  return false;
47 
48  printf( "received a vcard tag!!!!!!!!!! %s\n", tag->xml().c_str() );
49 
50  gloox::IQ re( gloox::IQ::Result, tag->findAttribute( "from" ),
51  tag->findAttribute( "id" ) );
52  re.setFrom( tag->findAttribute( "to" ) );
53  re.addExtension( new gloox::VCard() );
54  m_router.handleIncomingTag( re.tag() );
55 
56  return true;
57  }
58 
59 
60 }