2
Kopete Groupwise Protocol
3
joinconferencetask.cpp - Join a conference on the server, after having been invited.
5
Copyright (c) 2004 SUSE Linux AG http://www.suse.com
7
Based on Iris, Copyright (C) 2003 Justin Karneges <justin@affinix.com>
9
Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
11
*************************************************************************
13
* This library is free software; you can redistribute it and/or *
14
* modify it under the terms of the GNU Lesser General Public *
15
* License as published by the Free Software Foundation; either *
16
* version 2 of the License, or (at your option) any later version. *
18
*************************************************************************
24
#include "userdetailsmanager.h"
26
#include "joinconferencetask.h"
28
JoinConferenceTask::JoinConferenceTask(Task* parent): RequestTask(parent)
32
JoinConferenceTask::~JoinConferenceTask()
36
void JoinConferenceTask::join( const GroupWise::ConferenceGuid & guid )
39
Field::FieldList lst, tmp;
40
tmp.append( new Field::SingleField( Field::NM_A_SZ_OBJECT_ID, 0, NMFIELD_TYPE_UTF8, guid ) );
41
lst.append( new Field::MultiField( Field::NM_A_FA_CONVERSATION, NMFIELD_METHOD_VALID, 0, NMFIELD_TYPE_ARRAY, tmp ) );
42
createTransfer( "joinconf", lst );
45
bool JoinConferenceTask::take( Transfer * transfer )
47
if ( forMe( transfer ) )
49
client()->debug( "JoinConferenceTask::take()" );
50
Response * response = dynamic_cast<Response *>( transfer );
51
Field::FieldList responseFields = response->fields();
52
// if the request was successful
53
if ( response->resultCode() == GroupWise::None )
55
// extract the list of participants and store them
56
Field::MultiField * participants = responseFields.findMultiField( Field::NM_A_FA_CONTACT_LIST );
59
Field::SingleField * contact = 0;
60
Field::FieldList contactList = participants->fields();
61
const Field::FieldListIterator end = contactList.end();
62
for ( Field::FieldListIterator it = contactList.find( Field::NM_A_SZ_DN );
64
it = contactList.find( ++it, Field::NM_A_SZ_DN ) )
66
contact = static_cast<Field::SingleField *>( *it );
69
// HACK: lowercased DN
70
QString dn = contact->value().toString().toLower();
71
m_participants.append( dn );
72
// need to ask for details for these contacts
73
if ( !client()->userDetailsManager()->known( dn ) )
74
m_unknowns.append( dn );
79
setError( GroupWise::Protocol );
81
// now, extract the list of pending invites and store them
82
Field::MultiField * invitees = responseFields.findMultiField( Field::NM_A_FA_RESULTS );
85
Field::SingleField * contact = 0;
86
Field::FieldList contactList = invitees->fields();
87
const Field::FieldListIterator end = contactList.end();
88
for ( Field::FieldListIterator it = contactList.find( Field::NM_A_SZ_DN );
90
it = contactList.find( ++it, Field::NM_A_SZ_DN ) )
92
contact = static_cast<Field::SingleField *>( *it );
95
// HACK: lowercased DN
96
QString dn = contact->value().toString().toLower();
97
m_invitees.append( dn );
98
// need to ask for details for these contacts
99
if ( !client()->userDetailsManager()->known( dn ) )
100
m_unknowns.append( dn );
105
setError( GroupWise::Protocol );
107
if ( m_unknowns.empty() ) // ready to chat
109
client()->debug( "JoinConferenceTask::finished()" );
112
else // need to get some more details first
114
client()->debug( "JoinConferenceTask::slotReceiveUserDetails(), requesting details" );
115
connect( client()->userDetailsManager(),
116
SIGNAL(gotContactDetails(GroupWise::ContactDetails)),
117
SLOT(slotReceiveUserDetails(GroupWise::ContactDetails)) );
118
client()->userDetailsManager()->requestDetails( m_unknowns );
122
setError( response->resultCode() );
129
void JoinConferenceTask::slotReceiveUserDetails( const ContactDetails & details )
131
client()->debug( QString( "JoinConferenceTask::slotReceiveUserDetails() - got %1" ).arg( details.dn ) );
132
QStringList::Iterator it = m_unknowns.begin();
133
QStringList::Iterator end = m_unknowns.end();
134
for( ; it != end; ++it )
136
QString current = *it;
137
client()->debug( QString( " - can we remove %1?" ).arg(current ) );
138
if ( current == details.dn )
140
client()->debug( " - it is gone!" );
141
m_unknowns.erase( it );
145
client()->debug( QString( " - now %1 unknowns").arg( m_unknowns.count() ) );
146
if ( m_unknowns.empty() )
148
client()->debug( " - finished()" );
151
// would be better to count the number of received details and listen to the getdetails task's error signal.
154
// client()->debug( " - ERROR - we requested details for the list of chat participants/invitees, but the server did not send us all the details! - setting finished() anyway, so the chat can take place." );
159
QStringList JoinConferenceTask::participants() const
161
return m_participants;
164
QStringList JoinConferenceTask::invitees() const
169
GroupWise::ConferenceGuid JoinConferenceTask::guid() const
174
#include "joinconferencetask.moc"