119c15fecSAndrew Lindesay /* 219c15fecSAndrew Lindesay * Copyright 2014, Stephan Aßmus <superstippi@gmx.de>. 380a272eeSAndrew Lindesay * Copyright 2016-2018, Andrew Lindesay <apl@lindesay.co.nz>. 419c15fecSAndrew Lindesay * All rights reserved. Distributed under the terms of the MIT License. 519c15fecSAndrew Lindesay */ 619c15fecSAndrew Lindesay #ifndef WEB_APP_INTERFACE_H 719c15fecSAndrew Lindesay #define WEB_APP_INTERFACE_H 819c15fecSAndrew Lindesay 919c15fecSAndrew Lindesay 1019c15fecSAndrew Lindesay #include <Application.h> 1119c15fecSAndrew Lindesay #include <String.h> 1219c15fecSAndrew Lindesay #include <package/PackageVersion.h> 1319c15fecSAndrew Lindesay 1419c15fecSAndrew Lindesay #include "List.h" 1519c15fecSAndrew Lindesay 1619c15fecSAndrew Lindesay 1719c15fecSAndrew Lindesay class BDataIO; 1819c15fecSAndrew Lindesay class BMessage; 1919c15fecSAndrew Lindesay using BPackageKit::BPackageVersion; 2019c15fecSAndrew Lindesay 2119c15fecSAndrew Lindesay typedef List<BString, false> StringList; 2219c15fecSAndrew Lindesay 2319c15fecSAndrew Lindesay 2419c15fecSAndrew Lindesay class WebAppInterface { 2519c15fecSAndrew Lindesay public: 2619c15fecSAndrew Lindesay WebAppInterface(); 2719c15fecSAndrew Lindesay WebAppInterface(const WebAppInterface& other); 2819c15fecSAndrew Lindesay virtual ~WebAppInterface(); 2919c15fecSAndrew Lindesay 3019c15fecSAndrew Lindesay WebAppInterface& operator=(const WebAppInterface& other); 3119c15fecSAndrew Lindesay 3219c15fecSAndrew Lindesay void SetAuthorization(const BString& username, 3319c15fecSAndrew Lindesay const BString& password); 3419c15fecSAndrew Lindesay const BString& Username() const 3519c15fecSAndrew Lindesay { return fUsername; } 3619c15fecSAndrew Lindesay 3719c15fecSAndrew Lindesay void SetPreferredLanguage(const BString& language); 3819c15fecSAndrew Lindesay void SetArchitecture(const BString& architecture); 3919c15fecSAndrew Lindesay 4080a272eeSAndrew Lindesay status_t GetChangelog( 4119c15fecSAndrew Lindesay const BString& packageName, 4219c15fecSAndrew Lindesay BMessage& message); 4319c15fecSAndrew Lindesay 4419c15fecSAndrew Lindesay status_t RetrieveUserRatings( 4519c15fecSAndrew Lindesay const BString& packageName, 4619c15fecSAndrew Lindesay const BString& architecture, 4719c15fecSAndrew Lindesay int resultOffset, int maxResults, 4819c15fecSAndrew Lindesay BMessage& message); 4919c15fecSAndrew Lindesay 5019c15fecSAndrew Lindesay status_t RetrieveUserRating( 5119c15fecSAndrew Lindesay const BString& packageName, 5219c15fecSAndrew Lindesay const BPackageVersion& version, 5319c15fecSAndrew Lindesay const BString& architecture, 5419c15fecSAndrew Lindesay const BString& repositoryCode, 5519c15fecSAndrew Lindesay const BString& username, 5619c15fecSAndrew Lindesay BMessage& message); 5719c15fecSAndrew Lindesay 5819c15fecSAndrew Lindesay status_t CreateUserRating( 5919c15fecSAndrew Lindesay const BString& packageName, 6019c15fecSAndrew Lindesay const BString& architecture, 6119c15fecSAndrew Lindesay const BString& repositoryCode, 6219c15fecSAndrew Lindesay const BString& languageCode, 6319c15fecSAndrew Lindesay const BString& comment, 6419c15fecSAndrew Lindesay const BString& stability, 6519c15fecSAndrew Lindesay int rating, 6619c15fecSAndrew Lindesay BMessage& message); 6719c15fecSAndrew Lindesay 6819c15fecSAndrew Lindesay status_t UpdateUserRating( 6919c15fecSAndrew Lindesay const BString& ratingID, 7019c15fecSAndrew Lindesay const BString& languageCode, 7119c15fecSAndrew Lindesay const BString& comment, 7219c15fecSAndrew Lindesay const BString& stability, 7319c15fecSAndrew Lindesay int rating, bool active, 7419c15fecSAndrew Lindesay BMessage& message); 7519c15fecSAndrew Lindesay 7619c15fecSAndrew Lindesay status_t RetrieveScreenshot( 7719c15fecSAndrew Lindesay const BString& code, 7819c15fecSAndrew Lindesay int32 width, int32 height, 7919c15fecSAndrew Lindesay BDataIO* stream); 8019c15fecSAndrew Lindesay 8119c15fecSAndrew Lindesay status_t RequestCaptcha(BMessage& message); 8219c15fecSAndrew Lindesay 8319c15fecSAndrew Lindesay status_t CreateUser(const BString& nickName, 8419c15fecSAndrew Lindesay const BString& passwordClear, 8519c15fecSAndrew Lindesay const BString& email, 8619c15fecSAndrew Lindesay const BString& captchaToken, 8719c15fecSAndrew Lindesay const BString& captchaResponse, 8819c15fecSAndrew Lindesay const BString& languageCode, 8919c15fecSAndrew Lindesay BMessage& message); 9019c15fecSAndrew Lindesay 9119c15fecSAndrew Lindesay status_t AuthenticateUser(const BString& nickName, 9219c15fecSAndrew Lindesay const BString& passwordClear, 9319c15fecSAndrew Lindesay BMessage& message); 9419c15fecSAndrew Lindesay 9519c15fecSAndrew Lindesay private: 9619c15fecSAndrew Lindesay status_t _SendJsonRequest(const char* domain, 9719c15fecSAndrew Lindesay BString jsonString, uint32 flags, 9819c15fecSAndrew Lindesay BMessage& reply) const; 99*b45e8b1eSAndrew Lindesay status_t _SendJsonRequest(const char* domain, 100*b45e8b1eSAndrew Lindesay BDataIO* requestData, 101*b45e8b1eSAndrew Lindesay size_t requestDataSize, uint32 flags, 102*b45e8b1eSAndrew Lindesay BMessage& reply) const; 10319c15fecSAndrew Lindesay 10419c15fecSAndrew Lindesay private: 10519c15fecSAndrew Lindesay BString fUsername; 10619c15fecSAndrew Lindesay BString fPassword; 10719c15fecSAndrew Lindesay BString fLanguage; 10819c15fecSAndrew Lindesay static int fRequestIndex; 10919c15fecSAndrew Lindesay }; 11019c15fecSAndrew Lindesay 11119c15fecSAndrew Lindesay 11219c15fecSAndrew Lindesay #endif // WEB_APP_INTERFACE_H 113