summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/yahoo/libkyahoo/logintask.h
blob: 46ff5dc94e5f035349c6db99df2b11a4ec58c508 (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
/*
    Kopete Yahoo Protocol
    Handles logging into to the Yahoo service

    Copyright (c) 2004 Duncan Mac-Vicar P. <duncan@kde.org>

    Copyright (c) 2005 André Duffeck <duffeck@kde.org>

    Kopete (c) 2002-2005 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.      *
    *                                                                       *
    *************************************************************************
*/

#ifndef LOGINTASK_H
#define LOGINTASK_H

#include "task.h"
#include "yahootypes.h"

class TQString;
class YMSGTransfer;

namespace TDEIO
{
	class Job;
}

/**
@author Duncan Mac-Vicar
*/
class LoginTask : public Task
{
Q_OBJECT
  
public:
	LoginTask(Task *parent);
	~LoginTask();

	bool take(Transfer* transfer);
	virtual void onGo();

	void reset();
	void setStateOnConnect( Yahoo::Status status );
	void setVerificationWord( const TQString &word );

	const TQString &yCookie();
	const TQString &cCookie();
	const TQString &tCookie();
	const TQString &loginCookie();
protected:
	virtual bool forMe( const Transfer* transfer ) const;
	enum State { InitialState, SentVerify, GotVerifyACK, SentAuth, GotAuthACK, SentAuthResp };
	void sendVerify();
	void sendAuth(YMSGTransfer* transfer);
	void sendAuthResp(YMSGTransfer* transfer);
	void sendAuthResp_0x0b(const TQString &sn, const TQString &seed, uint sessionID);
	void sendAuthResp_pre_0x0b(const TQString &sn, const TQString &seed);
	void handleAuthResp(YMSGTransfer *transfer);
	void parseCookies( YMSGTransfer *transfer );
	void sendAuthSixteenStage1(const TQString& sn, const TQString& seed);
	void sendAuthSixteenStage2(const TQString& token);
	void sendAuthSixteenStage3(const TQString& cryptString);
protected slots:
	void handleAuthSixteenStage1Data(TDEIO::Job*, const TQByteArray& data);
	void handleAuthSixteenStage1Result(TDEIO::Job*);
	void handleAuthSixteenStage2Data(TDEIO::Job*, const TQByteArray& data);
	void handleAuthSixteenStage2Result(TDEIO::Job*);

signals:
	void haveSessionID( uint );
	void haveCookies();
	void loginResponse( int, const TQString& );
	void buddyListReady();
private:
	State mState;
	Yahoo::Status m_stateOnConnect;
	TQString m_yCookie;
	TQString m_tCookie;
	TQString m_cCookie;
	TQString m_loginCookie;
	TQString m_verificationWord;
	TQString m_stage1Data;
	TQString m_stage2Data;
	TQString m_challengeString;
	uint m_sessionID;
};

#endif