//**************************************************************************** //Copyright (C) 2005-2006 Beijing BlueDJ Technology Co.,Ltd. All rights reserved. //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either version 2 //of the License, or (at your option) any later version. //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //You should have received a copy of the GNU General Public License //along with this program (in the file LICENSE.GPL); if not, write to the Free Software //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //Please visit http://www.bluedj.com for more infomation about us. //Contact us at ggwizard@gmail.com or darkdong@gmail.com. //****************************************************************************/ #include "DJAdminBrowser.h" #include "DJGameController.h" #include "DJSchemeEvent.h" #include "Utility.h" #include "DJClientRequest.h" DJAdminBrowser::DJAdminBrowser( DJGameController* gameController, quint32 groupId, QWidget * parent ) : QTextBrowser( parent ),m_gameController(gameController),m_groupId(groupId) { djDebug() << "DJAdminBrowser constructor"; } DJAdminBrowser::~DJAdminBrowser() { djDebug() << "DJAdminBrowser destructor"; } QString DJAdminBrowser::extractCallAdminInfo( const ChatContent* pChatContent, CallAdminInfo& info ) { djDebug()<<"DJAdminBrowser::extractCallAdminInfo"; QString sentence = QString::fromUtf8( pChatContent->szSentence ); djDebug()<<"sentence="<> info.callerId; stream >> info.roomId; stream >> info.tableId; stream >> info.reason; stream >> info.eventType; sentence.remove( begin, end - begin + 2 ); } return sentence; } void DJAdminBrowser::receiveChat( const ChatContent* pChatContent ) { djDebug()<<"DJAdminBrowser::receiveChat"; CallAdminInfo info = {0}; QString sentence = extractCallAdminInfo( pChatContent, info ); djDebug()<"); text.append(""); append( text ); if ( !sentence.isEmpty() ) { text = tr("he/she said : ")+ sentence; text.prepend(""); text.append(""); append( text ); } text = DJSCHEME_AHREF .arg( DJSCHEME ) .arg( DJSCHEME_EVENT_CALL_ADMIN ) .arg( info.callerId ) .arg( DJSCHEME_HOST ) .arg( tr("pending call") ); //text.prepend(""); //text.append(""); append( text ); //text = toHtml(); //djDebug()<<"total text"<userid_speaker ); handlePendingCall( speakerId, info.callerId ); if ( speakerId == m_gameController->selfUserId() ) m_gameController->chatWithUser( info.callerId, true ); }else if ( ADMIN_CHAT_EVENT_TYPE_ADMIN_CHAT == info.eventType ) { djDebug()<<"admin chat"; quint32 speakerId = letoh4( &pChatContent->userid_speaker ); QString text = tr("admin %1 : ").arg(speakerId); text.append( sentence ); text.prepend(""); text.append(""); append( text ); } } void DJAdminBrowser::handlePendingCall( quint32 adminId, quint32 callerId ) { QString adminProcessed = tr("admin %1 has handled").arg(adminId); adminProcessed.prepend(""); adminProcessed.append(""); QString text = toHtml(); //djDebug()<<"total text"<", indexOfBegin ); if ( -1 != indexOfEnd ) { djDebug()<<"indexOfEnd"<(chatContent.data()); setle4( &pChatContent->userid_speaker, m_gameController->selfUserId() ); setle4( &pChatContent->userid_listener, m_groupId ); pChatContent->chGameClass = 0xFF; pChatContent->chGame = 0xFF; qstrcpy( pChatContent->szSentence, utf8.data() ); m_gameController->requestChat( pChatContent, chatContent.size() ); } } } QString DJAdminBrowser::reason( uint reason ) const { static const char *reasons[] = { QT_TR_NOOP("no reason"), QT_TR_NOOP("someone is cheating"), QT_TR_NOOP("someone is abusing"), QT_TR_NOOP("there is a question"), QT_TR_NOOP("there is a suggestion"), QT_TR_NOOP("curious"), QT_TR_NOOP("other reason") }; if ( reason < sizeof(reasons)/sizeof(reasons[0]) ) return tr(reasons[reason]); else return tr(reasons[0]); }