#ifndef LIB_NW_INTERNALS_H
#define LIB_NW_INTERNALS_H

#include <libnw.h>

struct _nwdev {
  nw_api_t api;             /* which code branch to use */

  guint32 folders;
  guint32 tracks;

  GList *folderlist;

  /* device-specific attributes */
  GHashTable *attributes;

  /* smarter syncing */
  gboolean autosync;
  gboolean dirty;

  /* API functions */
  void (*dev_free)( struct _nwdev * );
  gboolean (*dev_sync)( struct _nwdev * );
  GList *(*parse_directory)( struct _nwdev * );

  /* folder stuff */
  guint32 (*add_folder)( struct _nwdev *, gchar *, guint32 );
  gboolean (*del_folder)( struct _nwdev *, guint32 );
  guint32 (*ren_folder)( struct _nwdev *, guint32, gchar * );
  guint32 (*add_to_folder)( struct _nwdev *, guint32, struct _nwtrack *,
                            guint32, guint32 );

  /* track stuff */
  gboolean (*del_track)( struct _nwdev *, guint32 );

  guint32 (*get_track_size)( struct _nwtrack * );
  guint32 (*get_track_time)( struct _nwtrack * );
  guint32 (*get_track_frames)( struct _nwtrack * );
  guint16 (*get_next_track_number)( struct _nwdev * );

  /* filesystem access */
  struct _nwfile *(*fopen)( struct _nwdev *, guint32, guint32, const gchar *, char * );
  int (*fclose)( struct _nwfile * );
  int (*stat)( struct _nwdev *, guint32, struct stat * );
  int (*fseek)( struct _nwfile *, long, int );
  long (*ftell)( struct _nwfile *);
  size_t (*fread)( void *, size_t, size_t, struct _nwfile * );
  size_t (*fwrite)( void *, size_t, size_t, struct _nwfile * );

  /* allow functions to report on progress */
  void (* progress)( double percent, void *context );
};

struct _nwfolder {
  nw_device_t *device;
  gchar *name;
  GList *tracklist;

  void *folderdata;
};

struct _nwtrack {
  nw_device_t *device;
  nw_folder_t *parent;

  /* no corresponding ID3 tag for these */
  gchar *fullpath;
  gchar *filename;

  /* not the same as ID3 track number */
  guint32 tracknum;

  guint32 time;
  guint32 size;
  guint32 frames;

  struct id3_tag *id3tag;

  void *trackdata;
};

#endif

