Logo Search packages:      
Sourcecode: codeblocks version File versions  Download package

webresourcesmanager.h

#ifndef WEBRESOURCESMANAGER_H
#define WEBRESOURCESMANAGER_H

#include <wx/hashmap.h>
#include <wx/arrstr.h>
#include <vector>

/** \brief Class managing web resources */
00009 class WebResourcesManager
{
    public:

        /** \brief Class which does handle progress notifying operations */
00014         class ProgressHandler
        {
            public:

                /** \brief Values of predefined ids */
00019                 enum PredefinedIds
                {
                    idDownloadList = -1,
                    idDownloadConfig = -2
                };

                virtual ~ProgressHandler() {}

                /** \brief Notifying that new downlaod has been started
                 *  \return Some identifier that will be passed into other handler functions
                 */
                virtual int StartDownloading( const wxString& Url ) = 0;


                /** \brief Get progress change information, note if progres < 0, progress can not be calculated */
                virtual void SetProgress( float progress, int id ) = 0;

                /** \brief Notifying that job has been finished */
                virtual void JobFinished( int id ) = 0;

                /** \brief Notify about some error */
                virtual void Error( const wxString& info, int id ) = 0;
        };

        /** \brief Ctor */
        WebResourcesManager();

        /** \brief Dctor */
        ~WebResourcesManager();

        /** \brief Load list of detection configurations from given list of base urls */
        bool LoadDetectionConfigurations( const wxArrayString& baseUrls, ProgressHandler* handler = 0 );

        /** \brief Try to download library detection settings with given shortcode */
        bool LoadDetectionConfig( const wxString& shortcut, std::vector< char >& content, ProgressHandler* handler = 0 );


    private:

00058         struct DetectConfigurationEntry
        {
00060             wxString m_Url;                     ///< \brief Url to resource with configuration file
00061             wxString m_Sign;                    ///< \brief Digital sign for the resource file (may be empty)
00062             DetectConfigurationEntry* m_Next;   ///< \brief Next configuration in the chain
        };

        WX_DECLARE_STRING_HASH_MAP( DetectConfigurationEntry*, EntriesT );

        EntriesT m_Entries;

        void ClearEntries();

        bool DoDownload( const wxString& url, ProgressHandler* handler, std::vector< char >& arr );
};

#endif

Generated by  Doxygen 1.6.0   Back to index