2
Kopete Groupwise Protocol
3
ChatCountsTask.cpp - Task to update chatroom participant counts
5
Copyright (c) 2005 SUSE Linux Products GmbH http://www.suse.com
7
Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
9
*************************************************************************
11
* This library is free software; you can redistribute it and/or *
12
* modify it under the terms of the GNU Lesser General Public *
13
* License as published by the Free Software Foundation; either *
14
* version 2 of the License, or (at your option) any later version. *
16
*************************************************************************
25
#include "chatcountstask.h"
27
ChatCountsTask::ChatCountsTask(Task* parent): RequestTask(parent)
30
createTransfer( "chatcounts", lst );
34
ChatCountsTask::~ChatCountsTask()
38
bool ChatCountsTask::take( Transfer * transfer )
40
if ( !forMe( transfer ) )
42
Response * response = dynamic_cast<Response *>( transfer );
45
if ( response->resultCode() )
47
setError( response->resultCode() );
51
Field::FieldList responseFields = response->fields();
52
Field::MultiField * resultsArray = responseFields.findMultiField( Field::NM_A_FA_RESULTS );
55
setError( GroupWise::Protocol );
58
Field::FieldList counts = resultsArray->fields();
59
const Field::FieldListIterator end = counts.end();
60
for ( Field::FieldListIterator it = counts.find( Field::NM_A_FA_CHAT );
62
it = counts.find( ++it, Field::NM_A_FA_CHAT ) )
64
Field::MultiField * mf = static_cast<Field::MultiField *>( *it );
65
Field::FieldList chat = mf->fields();
68
// read the supplied fields, set metadata and status.
69
Field::SingleField * sf;
70
if ( ( sf = chat.findSingleField ( Field::NM_A_DISPLAY_NAME ) ) )
71
roomName = sf->value().toString();
72
if ( ( sf = chat.findSingleField ( Field::NM_A_UD_PARTICIPANTS ) ) )
73
participants = sf->value().toInt();
75
m_results.insert( roomName, participants );
80
QMap< QString, int > ChatCountsTask::results()
85
#include "chatcountstask.moc"