summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/gadu/gaducommands.h
blob: 2c56ba8a0a78b91b05dc8f9dfd0e1b34e0fe2b52 (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
147
148
149
150
// -*- Mode: c++-mode; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*-
//
// Copyright (C) 2003-2004 Grzegorz Jaskiewicz 	<gj at pointblue.com.pl>
// Copyright (C) 2002-2003	 Zack Rusin 	<zack@kde.org>
//
// gaducommands.h - all basic, and not-session dependent commands
// (meaning you don't have to be logged in for any of these).
// These delete themselves, meaning you don't
//  have to/can't delete them explicitly and have to create
//  them dynamically (via the 'new' call).
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301, USA.

#ifndef GADUCOMMANDS_H
#define GADUCOMMANDS_H

#include <libgadu.h>

#include <tqobject.h>

class QSocketNotifier;
class QStringList;
class QPixmap;

class GaduCommand : public QObject
{
	Q_OBJECT

public:
	GaduCommand( TQObject* parent = 0, const char* name = 0 );
	virtual ~GaduCommand();

	virtual void execute() = 0;

	bool done() const;

signals:
	//e.g. emit done( i18n("Done"), i18n("Registration complete") );
	void done( const TQString& title, const TQString& what );
	void error( const TQString& title, const TQString& error );
	void socketReady();
	void operationStatus( const TQString );

protected:
	void checkSocket( int, int );
	void enableNotifiers( int );
	void disableNotifiers();
	void deleteNotifiers();

	bool done_;

protected slots:
	void forwarder();

private:
	TQSocketNotifier*	read_;
	TQSocketNotifier*	write_;
};

class RegisterCommand : public GaduCommand
{
	Q_OBJECT

public:
	RegisterCommand( TQObject* parent = 0, const char* name = 0 );
	RegisterCommand( const TQString& email, const TQString& password ,
					TQObject* parent = 0, const char* name = 0 );
	~RegisterCommand();

	void setUserinfo( const TQString& email, const TQString& password, const TQString& token );
	void execute();
	unsigned int newUin();
	void requestToken();
	void cancel();

signals:
	void tokenRecieved( TQPixmap, TQString );

protected slots:
	void watcher();

private:
	enum RegisterState{ RegisterStateNoToken, RegisterStateWaitingForToken, RegisterStateGotToken, RegisterStateWaitingForNumber, RegisterStateDone };
	RegisterState	state;
	QString			email_;
	QString			password_;
	struct gg_http*	session_;
	int 			uin;
	QString			tokenId;
	QString			tokenString;
};

class RemindPasswordCommand : public GaduCommand
{
	Q_OBJECT

public:
	RemindPasswordCommand( uin_t uin, TQObject* parent = 0, const char* name = 0 );
	RemindPasswordCommand( TQObject* parent = 0, const char* name = 0 );
	~RemindPasswordCommand();

	void setUIN( uin_t );
	void execute();

protected slots:
	void watcher();

private:
	uin_t			uin_;
	struct gg_http*	session_;
};

class ChangePasswordCommand : public GaduCommand
{
	Q_OBJECT

public:
	ChangePasswordCommand( TQObject* parent = 0, const char* name = 0 );
	~ChangePasswordCommand();

	void setInfo( uin_t uin, const TQString& passwd, const TQString& newpasswd,
				const TQString& newemail );
	void execute();

protected slots:
	void watcher();

private:
	struct gg_http*	session_;
	QString			passwd_;
	QString			newpasswd_;
	QString			newemail_;
	uin_t			uin_;
};


#endif