00001 /* 00002 Copyright (c) 2005-2006 by Jakob Schroeter <js@camaya.net> 00003 This file is part of the gloox library. http://camaya.net/gloox 00004 00005 This software is distributed under a license. The full license 00006 agreement can be found in the file LICENSE in this distribution. 00007 This software may not be copied, modified, sold or distributed 00008 other than expressed in the named license agreement. 00009 00010 This software is distributed without any warranty. 00011 */ 00012 00013 00014 #include "messagefilter.h" 00015 00016 00017 namespace gloox 00018 { 00019 00020 MessageFilter::MessageFilter( MessageSession *parent ) 00021 : m_parent( 0 ) 00022 { 00023 if( parent ) 00024 attachTo( parent ); 00025 } 00026 00027 MessageFilter::~MessageFilter() 00028 { 00029 if( m_parent ) 00030 m_parent->removeMessageFilter( this ); 00031 } 00032 00033 void MessageFilter::attachTo( MessageSession *session ) 00034 { 00035 if( m_parent ) 00036 m_parent->removeMessageFilter( this ); 00037 00038 if( session ) 00039 session->registerMessageFilter( this ); 00040 00041 m_parent = session; 00042 } 00043 00044 }