summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/groupwise/libgroupwise/tasks/createconferencetask.cpp
blob: 8be16888502e0d8ee93574faaba404e923c1e6c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
    Kopete Groupwise Protocol
    createconferencetask.cpp - Request task that creates conferences on the server

    Copyright (c) 2004      SUSE Linux AG	 	 http://www.suse.com
    
    Based on Iris, Copyright (C) 2003  Justin Karneges

    Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
 
    *************************************************************************
    *                                                                       *
    * This library is free software; you can redistribute it and/or         *
    * modify it under the terms of the GNU Lesser General Public            *
    * License as published by the Free Software Foundation; either          *
    * version 2 of the License, or (at your option) any later version.      *
    *                                                                       *
    *************************************************************************
*/

#include "client.h"
#include "response.h"


#include "createconferencetask.h"

CreateConferenceTask::CreateConferenceTask(Task* parent): RequestTask(parent), m_confId( 0 ), m_guid( BLANK_GUID )
{

}

CreateConferenceTask::~CreateConferenceTask()
{
}

void CreateConferenceTask::conference( const int confId, const QStringList &participants )
{
	m_confId = confId;
	Field::FieldList lst, tmp;
	// list containing blank GUID
	tmp.append( new Field::SingleField( NM_A_SZ_OBJECT_ID, 0, NMFIELD_TYPE_UTF8, m_guid ) );
	lst.append( new Field::MultiField( NM_A_FA_CONVERSATION, NMFIELD_METHOD_VALID, 0, NMFIELD_TYPE_ARRAY, tmp ) );
	// series of participants (may be empty )
	QValueListConstIterator<QString> end = participants.end();
	for ( QValueListConstIterator<QString> it = participants.begin(); it != end; ++it )
		lst.append( new Field::SingleField( NM_A_SZ_DN, 0, NMFIELD_TYPE_DN, *it ) );
	lst.append( new Field::SingleField( NM_A_SZ_DN, 0, NMFIELD_TYPE_DN, client()->userDN() ) );
	createTransfer( "createconf", lst );
}

bool CreateConferenceTask::take( Transfer * transfer )
{
	if ( !forMe( transfer ) )
		return false;
	Response * response = dynamic_cast<Response *>( transfer );
	if ( !response )
		return false;
	
	// if the createconf was successful, read the GUID and store it
	Field::FieldList responseFields = response->fields();
	if ( response->resultCode() == GroupWise::None )
	{
		Field::MultiField * listField = responseFields.findMultiField( NM_A_FA_CONVERSATION );
		Field::FieldList guidList = listField->fields();
		Field::SingleField * guidField = guidList.findSingleField( NM_A_SZ_OBJECT_ID );
		m_guid = guidField->value().toString();
		setSuccess();
	}
	else
		setError( response->resultCode() );
	return true;
	
}

GroupWise::ConferenceGuid CreateConferenceTask::conferenceGUID() const
{
	return m_guid;
}

int CreateConferenceTask::clientConfId() const
{
	return m_confId;
}	

#include "createconferencetask.moc"