1 /*
2 Kopete Oscar Protocol
3 servicesetuptask.cpp - Set up the services for the BOS connection
4
5 Copyright (c) 2004 Matt Rogers <mattr@kde.org>
6
7 Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
8
9 *************************************************************************
10 * *
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. *
15 * *
16 *************************************************************************
17 */
18 #include "servicesetuptask.h"
19
20 #include <kdebug.h>
21 #include "blmlimitstask.h"
22 #include "connection.h"
23 #include "clientreadytask.h"
24 #include "icbmparamstask.h"
25 #include "locationrightstask.h"
26 #include "ownuserinfotask.h"
27 #include "prmparamstask.h"
28 #include "profiletask.h"
29 #include "senddcinfotask.h"
30 #include "sendidletimetask.h"
31 #include "ssiactivatetask.h"
32 #include "ssilisttask.h"
33 #include "contactmanager.h"
34 #include "ssiparamstask.h"
35 #include "transfer.h"
36 #include <QList>
37
ServiceSetupTask(Task * parent)38 ServiceSetupTask::ServiceSetupTask( Task* parent )
39 : Task( parent )
40 {
41 m_finishedTaskCount = 0;
42 m_locRightsTask = new LocationRightsTask( parent );
43 m_profileTask = new ProfileTask( parent );
44 m_blmLimitsTask = new BLMLimitsTask( parent );
45 m_icbmTask = new ICBMParamsTask( parent );
46 m_prmTask = new PRMParamsTask( parent );
47 m_ssiParamTask = new SSIParamsTask( parent );
48 m_ssiListTask = new SSIListTask( parent );
49 m_ssiActivateTask = new SSIActivateTask( parent );
50
51 m_profileTask->setCapabilities( true );
52
53 QObject::connect( m_ssiListTask, SIGNAL(finished()), this, SLOT(childTaskFinished()) );
54 QObject::connect( m_ssiParamTask, SIGNAL(finished()), this, SLOT(childTaskFinished()) );
55 QObject::connect( m_prmTask, SIGNAL(finished()), this, SLOT(childTaskFinished()) );
56 QObject::connect( m_icbmTask, SIGNAL(finished()), this, SLOT(childTaskFinished()) );
57 QObject::connect( m_blmLimitsTask, SIGNAL(finished()), this, SLOT(childTaskFinished()) );
58 QObject::connect( m_profileTask, SIGNAL(finished()), this, SLOT(childTaskFinished()) );
59 QObject::connect( m_locRightsTask, SIGNAL(finished()), this, SLOT(childTaskFinished()) );
60 QObject::connect( m_ssiActivateTask, SIGNAL(finished()), this, SLOT(childTaskFinished()) );
61 }
62
~ServiceSetupTask()63 ServiceSetupTask::~ServiceSetupTask()
64 {
65 delete m_locRightsTask;
66 delete m_profileTask;
67 delete m_blmLimitsTask;
68 delete m_icbmTask;
69 //delete m_prmTask;
70 //delete m_ssiParamTask;
71 delete m_ssiListTask;
72 }
73
forMe(const Transfer * transfer) const74 bool ServiceSetupTask::forMe( const Transfer* transfer ) const
75 {
76 Q_UNUSED( transfer );
77 return false;
78 }
79
take(Transfer * transfer)80 bool ServiceSetupTask::take( Transfer* transfer )
81 {
82 Q_UNUSED( transfer );
83 return false;
84 }
85
childTaskFinished()86 void ServiceSetupTask::childTaskFinished()
87 {
88 m_finishedTaskCount++;
89
90 // kDebug( OSCAR_RAW_DEBUG ) << "Finished count is " << m_finishedTaskCount;
91
92 if ( m_finishedTaskCount == 7 )
93 {
94 if ( client()->ssiManager()->listComplete() )
95 m_ssiActivateTask->go( Task::AutoDelete );
96
97 kDebug( OSCAR_RAW_DEBUG ) << "Sending DC info and client ready";
98 SendIdleTimeTask* sitt = new SendIdleTimeTask( client()->rootTask() );
99 QList<int> familyList;
100 familyList.append( 0x0001 );
101 familyList.append( 0x0002 );
102 familyList.append( 0x0003 );
103 familyList.append( 0x0004 );
104 familyList.append( 0x0006 );
105 familyList.append( 0x0008 );
106 familyList.append( 0x0009 );
107 familyList.append( 0x000A );
108 familyList.append( 0x0013 );
109 ClientReadyTask* crt = new ClientReadyTask( client()->rootTask() );
110 crt->setFamilies( familyList );
111 sitt->go( Task::AutoDelete );
112 crt->go( Task::AutoDelete ); //autodelete
113 }
114
115 if ( m_finishedTaskCount == 8 )
116 {
117 kDebug( OSCAR_RAW_DEBUG ) << "Service setup finished";
118 setSuccess( 0, QString() );
119 }
120 }
121
onGo()122 void ServiceSetupTask::onGo()
123 {
124 m_locRightsTask->go();
125 m_profileTask->go();
126 m_blmLimitsTask->go();
127 m_icbmTask->go();
128 m_prmTask->go( Task::AutoDelete );
129 m_ssiParamTask->go( Task::AutoDelete );
130 m_ssiListTask->go();
131 }
132
133