File indexing completed on 2025-01-19 04:24:27
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef IPODDEVICEHELPER_H 0018 #define IPODDEVICEHELPER_H 0019 0020 #include "ui_IpodConfiguration.h" 0021 #include "amarok_export.h" 0022 #include "core/transcoding/TranscodingConfiguration.h" 0023 0024 #include <QDialog> 0025 0026 #include <QString> 0027 0028 #include <gpod/itdb.h> 0029 0030 0031 namespace IpodDeviceHelper { 0032 0033 /** 0034 * Tries to parse itunes db from an iPod mounted at @param mountPoint . 0035 * @param errorMsg is set appropriately if error occurred 0036 * @return valid itdb or null, in which case @param errorMsg is not empty 0037 */ 0038 AMAROK_EXPORT Itdb_iTunesDB *parseItdb( const QString &mountPoint, QString &errorMsg ); 0039 0040 /** 0041 * Return pretty iPod name usable as collection name. 0042 * @param itdb parsed iTunes db, may be null in which cese fallback name is used 0043 */ 0044 AMAROK_EXPORT QString collectionName( Itdb_iTunesDB *itdb ); 0045 0046 /** 0047 * Return iPod name without model, or placeholder if no or empty name can be read 0048 */ 0049 AMAROK_EXPORT QString ipodName( Itdb_iTunesDB *itdb ); 0050 0051 /** 0052 * Unlinks playlists and tracks from itdb so that itdb no longer frees them when it 0053 * itself is freed. Does nothing when itdb is null. 0054 */ 0055 AMAROK_EXPORT void unlinkPlaylistsTracksFromItdb( Itdb_iTunesDB *itdb ); 0056 0057 /** 0058 * Fills in a dialog with iPod configuration. 0059 * 0060 * @param configureDialog QDialog that contains the ui. Must not be null 0061 * @param mountPoint mount point 0062 * @param configureDialogUi ui of the dialog. Must not be null 0063 * @param itdb itdb of the device or null if could not be parsed 0064 * @param transcodeConfig current transcoding configuration preference 0065 * @param errorMessage from parsing/initializing itsb (empty if no error) 0066 */ 0067 AMAROK_EXPORT void fillInConfigureDialog( QDialog *configureDialog, 0068 Ui::IpodConfiguration *configureDialogUi, 0069 const QString &mountPoint, 0070 Itdb_iTunesDB *itdb, 0071 const Transcoding::Configuration &transcodeConfig, 0072 const QString &errorMessage = QString() ); 0073 0074 /** 0075 * Try to initialize iPod using libgpod. 0076 * 0077 * @param mountPoint mount point of an already mounted iPod 0078 * @param configureDialogUi configure dialog ui from which some info is gathered 0079 * @param errorMessage if initializing fails, errorMessage will contain problem 0080 * 0081 * @return true if initialization succeeded, false otherwise 0082 */ 0083 AMAROK_EXPORT bool initializeIpod( const QString& mountPoint, 0084 const Ui::IpodConfiguration *configureDialogUi, 0085 QString &errorMessage ); 0086 0087 /** 0088 * Sets iPod name to @param newName . Does nothing if @param itdb is null 0089 */ 0090 AMAROK_EXPORT void setIpodName( Itdb_iTunesDB *itdb, const QString &newName ); 0091 0092 /** 0093 * Return true if it is considered safe to write to itdb. itdb can be null and this 0094 * function is guaranteed to return false in such case. 0095 * 0096 * @param mountPoint path to a mounted ipod 0097 * @param itdb iTunes database, may be null 0098 */ 0099 AMAROK_EXPORT bool safeToWrite( const QString &mountPoint, const Itdb_iTunesDB *itdb ); 0100 0101 } // namespace IpodDeviceHelper 0102 0103 #endif // IPODDEVICEHELPER_H