/*******************************************************************
          FILE:          index.h
   DESCRIPTION:          Main application web page header
 *******************************************************************/
#ifndef __CYINDEX_H
#define __CYINDEX_H
#include <string>
#include <sstream>
#include <pthread.h>
#include <unistd.h>
///////////////////////////////////////////
//  Header file(s)
#include "cyw_js.h"
/***************************************************************************
         CLASS:          cyindex
   DESCRIPTION:          Index web page class
 ***************************************************************************/
class                    cyindex
{
public:
    ///////////////////////////////////////
    //  Constructor/Destructor
    cyindex (cyjs* js,
             std::string inisection,
             std::string cginame="");
    virtual ~cyindex ();
    //////////////////////////////////////
    //  Page method(s)
    std::string         page_about ();
    std::string         page_default ();
    std::string         page_treemenu ();
    std::string         page_settings ();
    std::string         page_credentials ();
    //////////////////////////////////////
    //  Access method(s)
    std::string         errormsg () { return _error.str (); }
    //////////////////////////////////////
    //  Shopify function(s)
    virtual bool        app_hmac ();
    virtual bool        app_oauth ();
    virtual bool        app_connect ();
    virtual bool        app_license (bool& exists);
    virtual bool        app_log (std::string hooktype);
    virtual bool        shopify_authenticate (std::string& html);
    //////////////////////////////////////
    //  Attribute(s)
    std::string         _appname, _appcgi,
                        _appcode, _dbinstall,
                        _hmac, _token, _shopname,
                        _dbpath, _request, _payload,
                        _apikey, _apiscope, _apisecret;
protected:
    //////////////////////////////////////
    //  Protected attribute(s)
    cyjs*               _js;         // JS object
    std::string         _cginame,    // The name of the CGI
                        _inisection; // DB connection from INI file
    std::stringstream   _error;
};
#endif
