xref: /haiku/src/apps/haikudepot/model/Captcha.h (revision 835e7239d03992421ebb46ba5d152f2d889dbf80)
1*835e7239SAndrew Lindesay /*
2*835e7239SAndrew Lindesay  * Copyright 2019, Andrew Lindesay <apl@lindesay.co.nz>.
3*835e7239SAndrew Lindesay  *
4*835e7239SAndrew Lindesay  * All rights reserved. Distributed under the terms of the MIT License.
5*835e7239SAndrew Lindesay  */
6*835e7239SAndrew Lindesay #ifndef CAPTCHA_H
7*835e7239SAndrew Lindesay #define CAPTCHA_H
8*835e7239SAndrew Lindesay 
9*835e7239SAndrew Lindesay 
10*835e7239SAndrew Lindesay #include <Archivable.h>
11*835e7239SAndrew Lindesay #include <String.h>
12*835e7239SAndrew Lindesay 
13*835e7239SAndrew Lindesay class BPositionIO;
14*835e7239SAndrew Lindesay 
15*835e7239SAndrew Lindesay /*!	When a user has to perform some sensitive operation, it is necessary to make
16*835e7239SAndrew Lindesay 	sure that it is not a 'robot' or software system that is acting as if it
17*835e7239SAndrew Lindesay 	were a person.  It is necessary to know that a real person is acting.  In
18*835e7239SAndrew Lindesay 	this case a graphical puzzle is presented to the user that presumably only
19*835e7239SAndrew Lindesay 	a human operator could solve.  This is called a Captcha.
20*835e7239SAndrew Lindesay */
21*835e7239SAndrew Lindesay 
22*835e7239SAndrew Lindesay class Captcha : public BArchivable {
23*835e7239SAndrew Lindesay public:
24*835e7239SAndrew Lindesay 								Captcha(BMessage* from);
25*835e7239SAndrew Lindesay 								Captcha();
26*835e7239SAndrew Lindesay 	virtual						~Captcha();
27*835e7239SAndrew Lindesay 
28*835e7239SAndrew Lindesay 	const	BString&			Token() const;
29*835e7239SAndrew Lindesay 			BPositionIO*		PngImageData() const;
30*835e7239SAndrew Lindesay 
31*835e7239SAndrew Lindesay 			void				SetToken(const BString& value);
32*835e7239SAndrew Lindesay 			void				SetPngImageData(const void* data, size_t len);
33*835e7239SAndrew Lindesay 
34*835e7239SAndrew Lindesay 			status_t			Archive(BMessage* into, bool deep = true) const;
35*835e7239SAndrew Lindesay private:
36*835e7239SAndrew Lindesay 			BString				fToken;
37*835e7239SAndrew Lindesay 			BMallocIO*			fPngImageData;
38*835e7239SAndrew Lindesay };
39*835e7239SAndrew Lindesay 
40*835e7239SAndrew Lindesay 
41*835e7239SAndrew Lindesay #endif // CAPTCHA_H
42