summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/oscar/liboscar/logintask.h
blob: 3e1a21c59fb691903e3dba1098a8d17b88768ad5 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
    Kopete Oscar Protocol
    logintask.h - Handles logging into to the AIM or ICQ service

    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.      *
    *                                                                       *
    *************************************************************************
*/

#ifndef _OSCAR_LOGINTASK_H_
#define _OSCAR_LOGINTASK_H_

#include <tqcstring.h>
#include "oscartypes.h"
#include "task.h"

#include "aimlogintask.h"
#include "icqlogintask.h"
#include "closeconnectiontask.h"

using namespace Oscar;

class TQString;
class Transfer;


/**
 * \short Handle OSCAR login - stage 1
 *
 * OSCAR login is divided into two stages. The first stage handles the connection negotiation
 * so that we can get a BOS server to connect to and start stage two of the login process
 * This class handles the first stage of the OSCAR login process
 * For more info about the OSCAR login process, visit http://iserverd1.khstu.ru/oscar
 */
class StageOneLoginTask : public Task
{
Q_OBJECT
  
public:
	StageOneLoginTask( Task* parent );
	~StageOneLoginTask();
	bool take( Transfer* transfer );

	//Protocol specific stuff
	
	//! Get the BOS cookie
	const TQByteArray& loginCookie() const;
	
	//! Get the BOS server
	const TQString& bosServer() const;

	//! Get the BOS port
	const TQString& bosPort() const;

	//! Get the error code, if there is one
	int errorCode() const;

	//! Get the error reason so it can be displayed
	const TQString& errorReason() const;


public slots:
	void closeTaskFinished();
	void aimTaskFinished();

protected:
	bool forMe( Transfer* transfer ) const;

private:
	
	//Tasks we want to control
	AimLoginTask* m_aimTask;
	IcqLoginTask* m_icqTask;
	CloseConnectionTask* m_closeTask;

	//Private data we get from the tasks
	TQByteArray m_cookie;
	TQString m_bosServer;
	TQString m_bosPort;

};

/**
 * \short Handle OSCAR Login - stage 2
 *
 * Oscar login is divided into two stages. The first stage handles the connection negotiation
 * so that we can get a BOS server to connect to for the second stage. This class handles the
 * second stage of Oscar login that establishes various things like rate limits, contact lists,
 * and SNAC family versions
 */

class ServerVersionsTask;
class RateInfoTask;

class StageTwoLoginTask : public Task
{
Q_OBJECT
  
public:
	StageTwoLoginTask( Task* parent );
	~StageTwoLoginTask();
	bool take( Transfer* transfer );
	void onGo();

	//protocol specifics
	//! Set the cookie to send to the server
	void setCookie( const TQByteArray& newCookie );
	
	//! Get the cookie to send to the server
	const TQByteArray& cookie();

	TQString host() const;
	TQString port() const;

public slots:

	//! Start the rate info task
	void versionTaskFinished();
	
	//! The rate info task is finished. Start the other ones
	void rateTaskFinished();
	
protected:
	bool forMe( Transfer* transfer ) const;

private:
	TQByteArray m_cookie;
	TQString m_host, m_port;

	//tasks
	ServerVersionsTask* m_versionTask;
	RateInfoTask* m_rateTask;
};

#endif

//kate: tab-width 4; indent-mode csands;