gloox 1.0
|
00001 /* 00002 Copyright (c) 2007-2009 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 #include "receipt.h" 00014 #include "tag.h" 00015 #include "util.h" 00016 00017 namespace gloox 00018 { 00019 00020 /* chat state type values */ 00021 static const char* receiptValues [] = { 00022 "request", 00023 "received" 00024 }; 00025 00026 static inline Receipt::ReceiptType receiptType( const std::string& type ) 00027 { 00028 return (Receipt::ReceiptType)util::lookup( type, receiptValues ); 00029 } 00030 00031 Receipt::Receipt( const Tag* tag ) 00032 : StanzaExtension( ExtReceipt ), 00033 m_rcpt( receiptType( tag->name() ) ) 00034 { 00035 } 00036 00037 const std::string& Receipt::filterString() const 00038 { 00039 static const std::string filter = 00040 "/message/request[@xmlns='" + XMLNS_RECEIPTS + "']" 00041 "|/message/received[@xmlns='" + XMLNS_RECEIPTS + "']"; 00042 return filter; 00043 } 00044 00045 Tag* Receipt::tag() const 00046 { 00047 if( m_rcpt == Invalid ) 00048 return 0; 00049 00050 return new Tag( util::lookup( m_rcpt, receiptValues ), XMLNS, XMLNS_RECEIPTS ); 00051 } 00052 00053 }