1 /* 2 | Copyright (C) 2002-2007 Jorg Schuler <jcsjcs at users sourceforge net> 3 | Part of the gtkpod project. 4 | 5 | URL: http://www.gtkpod.org/ 6 | URL: http://gtkpod.sourceforge.net/ 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | iTunes and iPod are trademarks of Apple 23 | 24 | This product is not supported/written/published by Apple! 25 | 26 | $Id$ 27 */ 28 29 #ifndef __DISPLAY_ITDB_H__ 30 #define __DISPLAY_ITDB_H__ 31 32 #ifdef HAVE_CONFIG_H 33 # include <config.h> 34 #endif 35 36 #include <gtk/gtk.h> 37 #include "itdb.h" 38 #include "file_convert.h" 39 40 struct itdbs_head 41 { 42 GList *itdbs; 43 }; 44 45 typedef struct 46 { 47 struct itdbs_head *itdbs_head; /* pointer to the master itdbs_head */ 48 GHashTable *sha1hash; /* sha1 hash information */ 49 GHashTable *pc_path_hash; /* hash with local filenames */ 50 GList *pending_deletion; /* tracks marked for removal from 51 media */ 52 gchar *offline_filename; /* filename for offline database 53 (only for GP_ITDP_TYPE_IPOD) */ 54 gboolean offline; /* offline mode? */ 55 gboolean data_changed; /* data changed since import? */ 56 gboolean photo_data_changed; /* photo data changed since import? */ 57 gboolean itdb_imported; /* has in iTunesDB been imported? */ 58 gboolean ipod_ejected; /* if iPod was ejected */ 59 PhotoDB *photodb; /* Photo DB reference used if the ipod supports photos */ 60 } ExtraiTunesDBData; 61 62 typedef struct 63 { 64 glong size; 65 } ExtraPlaylistData; 66 67 typedef struct 68 { 69 gchar *year_str; /* year as string -- always identical to year */ 70 gchar *pc_path_locale; /* path on PC (local encoding) */ 71 gchar *pc_path_utf8; /* PC filename in utf8 encoding */ 72 time_t mtime; /* modification date of PC file */ 73 gboolean pc_path_hashed; /* for programming error detection (see 74 gp_itdb_local_path_hash_add_track() */ 75 gchar *converted_file; /* if converted file exists: name in utf8 */ 76 gint32 orig_filesize; /* size of original file (if converted) */ 77 FileConvertStatus conversion_status; /* current status of conversion */ 78 gchar *thumb_path_locale;/* same for thumbnail */ 79 gchar *thumb_path_utf8; /* same for thumbnail */ 80 gchar *hostname; /* name of host this file has been imported on */ 81 gchar *sha1_hash; /* sha1 hash of file (or NULL) */ 82 gchar *charset; /* charset used for ID3 tags */ 83 gint32 sortindex; /* used for stable sorting (current order) */ 84 gboolean tchanged; /* temporary use, e.g. in detail.c */ 85 gboolean tartwork_changed; /* temporary use for artwork, eg. in detail.c */ 86 guint64 local_itdb_id; /* when using DND from local to iPod: 87 original itdb */ 88 guint64 local_track_dbid; /* when using DND from local to iPod: 89 original track */ 90 gchar *lyrics; /* Lyrics information as read from file or as 91 updated in the program */ 92 } ExtraTrackData; 93 94 /* types for iTunesDB */ 95 typedef enum 96 { 97 GP_ITDB_TYPE_LOCAL = 1<<0, /* local browsing, normal music */ 98 GP_ITDB_TYPE_IPOD = 1<<1, /* iPod */ 99 GP_ITDB_TYPE_PODCASTS = 1<<2, /* local browsing, podcasts */ 100 GP_ITDB_TYPE_AUTOMATIC = 1<<3,/* repository was automounted */ 101 } GpItdbType; 102 103 /* Delete actions */ 104 typedef enum 105 { 106 /* remove from playlist only -- cannot be used on MPL */ 107 DELETE_ACTION_PLAYLIST = 0, 108 /* remove from iPod (implicates removing from database) */ 109 DELETE_ACTION_IPOD, 110 /* remove from local harddisk (implicates removing from database) */ 111 DELETE_ACTION_LOCAL, 112 /* remove from database only */ 113 DELETE_ACTION_DATABASE 114 } DeleteAction; 115 116 struct DeleteData 117 { 118 iTunesDB *itdb; 119 Playlist *pl; 120 GList *tracks; 121 DeleteAction deleteaction; 122 }; 123 124 void init_data (GtkWidget *window); 125 iTunesDB *setup_itdb_n (gint i); 126 127 struct itdbs_head *gp_get_itdbs_head (GtkWidget *gtkpod_win); 128 129 iTunesDB *gp_itdb_new (void); 130 void gp_itdb_add (iTunesDB *itdb, gint pos); 131 void gp_itdb_remove (iTunesDB *itdb); 132 void gp_itdb_free (iTunesDB *itdb); 133 void gp_replace_itdb (iTunesDB *old_itdb, iTunesDB *new_itdb); 134 void gp_itdb_add_extra (iTunesDB *itdb); 135 void gp_itdb_add_extra_full (iTunesDB *itdb); 136 137 Track *gp_track_new (void); 138 #define gp_track_free itdb_track_free 139 Track *gp_track_add (iTunesDB *itdb, Track *track); 140 void gp_track_remove (Track *track); 141 void gp_track_unlink (Track *track); 142 void gp_track_add_extra (Track *track); 143 void gp_track_validate_entries (Track *track); 144 gboolean gp_track_set_thumbnails (Track *track, const gchar *filename); 145 gboolean gp_track_set_thumbnails_from_data (Track *track, 146 const guchar *image_data, 147 gsize image_data_len); 148 gboolean gp_track_remove_thumbnails (Track *track); 149 150 Playlist *gp_playlist_new (const gchar *title, gboolean spl); 151 void gp_playlist_add (iTunesDB *itdb, Playlist *pl, gint32 pos); 152 void gp_playlist_remove (Playlist *pl); 153 guint gp_playlist_remove_by_name (iTunesDB *itdb, gchar *pl_name); 154 Playlist *gp_playlist_add_new (iTunesDB *itdb, gchar *name, 155 gboolean spl, gint32 pos); 156 Playlist *gp_playlist_by_name_or_add (iTunesDB *itdb, gchar *pl_name, 157 gboolean spl); 158 void gp_playlist_remove_track (Playlist *plitem, Track *track, 159 DeleteAction deleteaction); 160 void gp_playlist_add_track (Playlist *pl, Track *track, gboolean display); 161 162 void gp_playlist_add_extra (Playlist *pl); 163 164 gboolean gp_increase_playcount (gchar *sha1, gchar *file, gint num); 165 iTunesDB *gp_get_selected_itdb (void); 166 iTunesDB *gp_get_ipod_itdb (void); 167 iTunesDB *gp_get_podcast_itdb (void); 168 #endif 169