/***************************************************************************
 *   Copyright (C) 2005 by Reel Multimedia                                 *
 *                                                                         *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#ifndef P__BROWSERSTATUS_H
#define P__BROWSERSTATUS_H

#include <string>

#include <vdr/status.h>

#include "fileType.h"

//----------cFileBrowserStatus-------------------- 

enum browseMode
{
    restricted, expert, autostart, browseplaylist
};

enum xineControl
{
    xine_browse, xine_edit, xine_exit
};

enum browserCaller
{
    normal, autorestart, svdrp, mediaplayer, xine
};

class cFileBrowserStatus: public cStatus
{
public:
    cFileBrowserStatus();
    ~cFileBrowserStatus(){};
    /*override*/ void Replaying(const cControl *Control, const char *Name, const char *FileName, bool On);

    //only called from service if/plugin
    //set the start dir and file
    void SetStartDir(std::string dir, std::string file);     
    //Filebrowser will be called by caller;
    void SetCaller(browserCaller caller);
    //Service call "filebrowser xine control" has been received 
    void XineControl(xineControl cmd);
    //Service call "Filebrowser set playlist" has been received 
    void SetPlayList(std::string path); 
    //Service call "Filebrowser set playlist entry" has been received 
    void SetPlayListEntry(std::string path);

    //are called from filebrowser menus
    //browse mode has been set
    void SetMode(browseMode);
    //filebrowser has been shut down with current dir and file
    void Shutdown(std::string dir, std::string file, std::string playlist, std::string playlistEntry);
    //main menu action has been called
    void Startup();
    //filebrowser has been constructed
    void Started();
    //xine has been started
    void XineStarted();
    //Playlist mode has been entered/exited
    void PlayListActive(bool On);
    //filebrowser has received kBack key
    void NormalExit();

    bool PlayListIsActive() const;
    bool XineIsStarted() const;
    bool IsCalledFromSvdrp() const; 
    bool EnterPlayList() const;
    bool ClosePlayList() const;
    browseMode GetMode() const; 
    std::string GetExitDir() const;
    std::string GetStartDir() const;
    std::string GetStartFile() const; 
    std::string GetPlayList() const;
    std::string GetPlayListEntry() const;
    uint GetFilter() const;

private:
    bool active_;
    bool running_;
    bool restarting_;
    bool playListActive_;
    bool xineStarted_;
    bool normalExit_;
    bool enterPlayList_;
    bool closePlayList_;
    browseMode mode_;
    browserCaller caller_; 
    xineControl xineCtrl_;
    uint filter_;

    std::string exitDir_;
    std::string startDir_;
    std::string startFile_;
    std::string playList_;
    std::string playListEntry_;

    void SetExitDir(std::string dir);
    void SetFilter();
};

//inline
    inline void cFileBrowserStatus::SetPlayList(std::string path)
    {
        playList_ = path;
    }
    inline void cFileBrowserStatus::SetPlayListEntry(std::string entry)
    {
        playListEntry_ = entry;
    }
    inline void cFileBrowserStatus::XineStarted()
    {
        xineStarted_ = true; 
    }
    inline void cFileBrowserStatus::PlayListActive(bool On)
    {
        playListActive_ = On;
    }
    inline void cFileBrowserStatus::NormalExit()
    {
        normalExit_ = true;
    }
    inline bool cFileBrowserStatus::PlayListIsActive() const
    {
        return playListActive_;
    }
    inline bool cFileBrowserStatus::XineIsStarted() const
    {
        return xineStarted_;
    }
    inline bool cFileBrowserStatus::EnterPlayList() const
    {
        return enterPlayList_; 
    }
    inline bool cFileBrowserStatus::ClosePlayList() const
    {
        return closePlayList_; 
    }
    inline browseMode cFileBrowserStatus::GetMode() const
    {
        return mode_;
    }
    inline std::string cFileBrowserStatus::GetExitDir() const
    {
        return exitDir_;
    }
    inline std::string cFileBrowserStatus::GetStartDir() const
    {
        return startDir_;
    }
    inline std::string cFileBrowserStatus::GetStartFile() const
    {
        return startFile_;
    }
    inline std::string cFileBrowserStatus::GetPlayList() const
    {
        return playList_;
    }
    inline std::string cFileBrowserStatus::GetPlayListEntry() const
    {
        return playListEntry_;
    }
    inline uint cFileBrowserStatus::GetFilter() const
    {
        return filter_;
    }
    inline void cFileBrowserStatus::SetExitDir(std::string dir)
    {
        exitDir_ = dir;
    }

#endif //P__BROWSERSTATUS_H
