/***************************************************************************
 *   Copyright (C) 2006 by Jens Koehler                                    *
 *   irimi_at_gmx_de                                                       *
 *                                                                         *
 *   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 AMAROKDATA_H_
#define AMAROKDATA_H_


#include <vector>
#include <string>
#include "commands.h"

#define MAX_ITEM_CHAR_SIZE 82

/////////////////////////////////////////////////////////////////////////
////////// PlaylistItem
/////////////////////////////////////////////////////////////////////////

class PlaylistItem
{
public:
    PlaylistItem(const char* title,const char* album,const char* artist,const char *genre,const char* length,const char* br, const char* year, const char* comment);

    const char *Title;
    const char *Album;
    const char *Artist;
    const char *Genre;
    const char *Length;
    const char *Bitrate;
    const char *Year;
    const char *Comment;
    void getShortTextContent(char *str,int index=0);

};

/////////////////////////////////////////////////////////////////////////
////////// TrackItem
/////////////////////////////////////////////////////////////////////////

class TrackItem : public PlaylistItem
{
public:

    int Index;
    int TrackSum;
    int PlayCounter;


    std::string Statistics;

    TrackItem(PlaylistItem* item, int index, int SumTracks, const std::string& stats);
    void getFormatTimeTrIdx(char* str,const char* preTime,const char* preTrack,int cTime=0,bool less=false);

};

/////////////////////////////////////////////////////////////////////////
////////// AmarokData
/////////////////////////////////////////////////////////////////////////

class AmarokData
{

public:
    AmarokData(AMAROK_CMD type=CMD_REQUEST_SET);
    virtual ~AmarokData();
#ifdef AMAROK_DEBUG

    virtual void debugList();
#endif

    void addData(const std::string &str)
    {
        m_strCorelist.push_back(str);
    };


    AMAROK_CMD getType() const
    {
        return m_type;
    };

    void setType(AMAROK_CMD type)
    {
        m_type=type;
    };

    int getInteger();
    bool getBoolean();
    const char* getConstChar();
    const std::string getString() const;

    virtual void clearList();

    virtual void buildList()
    {

#ifdef AMAROK_DEBUG
        debugList();
#endif

    };

protected:

    std::vector<std::string> m_strCorelist;


private:
    AMAROK_CMD m_type;

};




/////////////////////////////////////////////////////////////////////////
////////// AmarokDataExt
/////////////////////////////////////////////////////////////////////////

class AmarokDataExt : public AmarokData
{
public:
    AmarokDataExt(AMAROK_CMD type);

    virtual void buildList()=0;
    virtual void clearList()=0;

#ifdef AMAROK_DEBUG

    virtual void debugList()
    {}
    ;
#endif


protected:

    void  getTagContent(const std::string &line, std::string &tag,const char** content );

};


/////////////////////////////////////////////////////////////////////////
////////// AmarokPlaylist
/////////////////////////////////////////////////////////////////////////

class AmarokPlaylist : public AmarokDataExt
{
public:
    AmarokPlaylist();
    ~AmarokPlaylist();
    void getPlaylistItem (PlaylistItem **item,unsigned int index=0 );
    void removePlaylistItem (unsigned int index);

    unsigned int getListSize () const
    {
        return m_playList.size();
    };

    void clearList();
    virtual void buildList();

#ifdef AMAROK_DEBUG

    void debugList();
#endif
protected:

    std::vector<PlaylistItem*> m_playList;


private:

};

/////////////////////////////////////////////////////////////////////////
////////// AmarokQueryResultItem
/////////////////////////////////////////////////////////////////////////

class AmarokQueryResultItem
{
public:
    AmarokQueryResultItem(const char* id);

    AmarokQueryResultItem();

    const char* getId() const
    {
        return p_id;
    };

    const char* getSubItem (unsigned int index );

    void addSubItem (const char* item)
    {
        m_SubItemlist.push_back(item);
    }
    unsigned int getSubItemSize () const
    {
        return m_SubItemlist.size();
    };

    void setShow(bool show=true)
    {
        b_SubShow=show;
    };
    bool getShow()const
    {
        return b_SubShow;
    };
private:

    const char* p_id;
    bool b_SubShow;
    std::vector<const char*> m_SubItemlist;


};



/////////////////////////////////////////////////////////////////////////
////////// AmarokQueryResultlist
/////////////////////////////////////////////////////////////////////////

class AmarokQueryResult : public AmarokDataExt
{
public:
    AmarokQueryResult();
    ~AmarokQueryResult();
    void getListItem (AmarokQueryResultItem **item,unsigned int index=0 );

    AmarokQueryResultItem* getItem(unsigned int index) const;
    AmarokQueryResultItem* getItemByOsdIndex(unsigned int index);
    unsigned int getNodeIndex(unsigned int osdIndex);
    bool getItemFormated(char *str,unsigned int index, unsigned int &subsize);
    bool getSubItemFormated(char *str,unsigned int index, unsigned int subindex);

    const char* getTextItemByOsdIndex(unsigned int search) const;

    unsigned int getListSize () const
    {
        return m_ResultList.size();
    };

    virtual void buildList();
    virtual void clearList();

#ifdef AMAROK_DEBUG

    void debugList();
#endif
protected:

    std::vector<AmarokQueryResultItem*> m_ResultList;



};


#endif

/*AMAROKDATA_H_*/

