summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/oscar/liboscar/servicesetuptask.cpp
blob: af4dd08ccbf76e9e9dea27b1b04b4003684819a5 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
	Kopete Oscar Protocol
	servicesetuptask.cpp - Set up the services for the BOS connection
	
	Copyright (c) 2004 Matt Rogers <[email protected]>
	
	Kopete (c) 2002-2004 by the Kopete developers <[email protected]>
	
	*************************************************************************
	*                                                                       *
	* 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 "servicesetuptask.h"

#include <kdebug.h>
#include "blmlimitstask.h"
#include "connection.h"
#include "clientreadytask.h"
#include "icbmparamstask.h"
#include "locationrightstask.h"
#include "ownuserinfotask.h"
#include "prmparamstask.h"
#include "profiletask.h"
#include "senddcinfotask.h"
#include "sendidletimetask.h"
#include "ssiactivatetask.h"
#include "ssilisttask.h"
#include "ssimanager.h"
#include "ssiparamstask.h"
#include "transfer.h"

ServiceSetupTask::ServiceSetupTask( Task* parent )
	: Task( parent )
{
	m_finishedTaskCount = 0;
	m_locRightsTask = new LocationRightsTask( parent );
	m_profileTask = new ProfileTask( parent );
	m_blmLimitsTask = new BLMLimitsTask( parent );
	m_icbmTask = new ICBMParamsTask( parent );
	m_prmTask = new PRMParamsTask( parent );
	m_ssiParamTask = new SSIParamsTask( parent );
	m_ssiListTask = new SSIListTask( parent );
	m_ssiActivateTask = new SSIActivateTask( parent );

	TQObject::connect( m_ssiListTask, TQT_SIGNAL( finished() ), this, TQT_SLOT( childTaskFinished() ) );
	TQObject::connect( m_ssiParamTask, TQT_SIGNAL( finished() ), this, TQT_SLOT( childTaskFinished() ) );
	TQObject::connect( m_prmTask, TQT_SIGNAL( finished() ), this, TQT_SLOT( childTaskFinished() ) );
	TQObject::connect( m_icbmTask, TQT_SIGNAL( finished() ), this, TQT_SLOT( childTaskFinished() ) );
	TQObject::connect( m_blmLimitsTask, TQT_SIGNAL( finished() ), this, TQT_SLOT( childTaskFinished() ) );
	TQObject::connect( m_profileTask, TQT_SIGNAL( finished() ), this, TQT_SLOT( childTaskFinished() ) );
	TQObject::connect( m_locRightsTask, TQT_SIGNAL( finished() ), this, TQT_SLOT( childTaskFinished() ) );
	TQObject::connect( m_ssiActivateTask, TQT_SIGNAL( finished() ), this, TQT_SLOT( childTaskFinished() ) );
}


ServiceSetupTask::~ServiceSetupTask()
{
	delete m_locRightsTask;
	delete m_profileTask;
	delete m_blmLimitsTask;
	delete m_icbmTask;
	//delete m_prmTask;
	//delete m_ssiParamTask;
	delete m_ssiListTask;
}


bool ServiceSetupTask::forMe( const Transfer* transfer ) const
{
	Q_UNUSED( transfer );
	return false;
}

bool ServiceSetupTask::take( Transfer* transfer )
{
	Q_UNUSED( transfer );
	return false;
}

void ServiceSetupTask::childTaskFinished()
{
	m_finishedTaskCount++;
	
// 	kdDebug( OSCAR_RAW_DEBUG ) << "Finished count is " << m_finishedTaskCount << endl;
	
	if ( m_finishedTaskCount == 7 )
	{
		if ( client()->ssiManager()->listComplete() )
			m_ssiActivateTask->go( true );

		kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Sending DC info and client ready" << endl;
		SendIdleTimeTask* sitt = new SendIdleTimeTask( client()->rootTask() );
		TQValueList<int> familyList;
		familyList.append( 0x0001 );
		familyList.append( 0x0002 );
		familyList.append( 0x0003 );
		familyList.append( 0x0004 );
		familyList.append( 0x0006 );
		familyList.append( 0x0008 );
		familyList.append( 0x0009 );
		familyList.append( 0x000A );
		familyList.append( 0x0013 );
		ClientReadyTask* crt = new ClientReadyTask( client()->rootTask() );
		crt->setFamilies( familyList );
		sitt->go( true );
		crt->go( true ); //autodelete
	}
	
	if ( m_finishedTaskCount == 8 )
	{
		kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Service setup finished" << endl;
		setSuccess( 0, TQString() );	
	}
}


void ServiceSetupTask::onGo()
{
	m_locRightsTask->go();
	m_profileTask->go();
	m_blmLimitsTask->go();
	m_icbmTask->go();
	m_prmTask->go( true );
	m_ssiParamTask->go( true );
	m_ssiListTask->go();
}
#include "servicesetuptask.moc"