glooxd  0.3-svn
presencemanager.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 "rosterprovider.h"
15 #include "presencemanager.h"
16 #include "taghandler.h"
17 #include "sm.h"
18 
19 #include <gloox/tag.h>
20 
21 #include <cstdio>
22 
23 namespace glooxd
24 {
25 
27  RosterProvider* rp )
28  : Plugin( sm, router ), m_handler( rp )
29  {
30  }
31 
33  {
34  }
35 
36  const std::string& PresenceManager::filterString() const
37  {
38  static const std::string filter = "/presence";
39  return filter;
40  }
41 
42  void PresenceManager::getRoster( const gloox::JID& jid )
43  {
44  if( m_handler )
45  {
46  const Roster& rm = m_handler->getRoster( jid );
47  Roster::const_iterator it = rm.begin();
48  for( ; it != rm.end(); ++it )
49  {
50  switch( (*it).second )
51  {
52  case gloox::S10nBoth:
53  break;
54  case gloox::S10nNone:
55  break;
56  case gloox::S10nFrom:
57  break;
58  case gloox::S10nTo:
59  break;
60  default:
61  break;
62  }
63  }
64  }
65  }
66 
67  bool PresenceManager::handleTag( const gloox::Tag* tag )
68  {
69  if( !tag || !m_handler )
70  return false;
71 
72  const std::string& type = tag->findAttribute( gloox::TYPE );
73  if( type == "subscribe" || type == "unsubscribe"
74  || type == "subscribed" || type == "unsubscribed" )
75  return false;
76 
77  printf( "received a presence tag!!!!!!!!!! %s\n", tag->xml().c_str() );
78 
79  m_sm.dispatchPresence( tag );
80 
81  return true;
82  }
83 
84 
85 }