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