sbMediaExportTaskWriter.h
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2009 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 #ifndef sbMediaExportTaskWriter_h_
26 #define sbMediaExportTaskWriter_h_
27 
28 #include "sbMediaExportDefines.h"
29 #include <nsCOMPtr.h>
30 #include <nsStringAPI.h>
31 #include <iostream>
32 #include <fstream>
33 #include <sbIMediaList.h>
34 #include <sbIMediaItem.h>
35 #include <nsNetUtil.h>
36 
38 {
39 public:
41  virtual ~sbMediaExportTaskWriter();
42 
44 
45  //
46  // \brief Initialize a task writer. This method will setup the necessary
47  // resources for writing the media export data to the task file.
48  //
49  nsresult Init();
50 
51  //
52  // \brief This method should be called when all the export data has been
53  // written out.
54  //
55  nsresult Finish();
56 
57  //
58  // \brief Write the header for the "added media lists" exported data.
59  //
60  nsresult WriteAddedMediaListsHeader();
61 
62  //
63  // \brief Write the header for the "removed media lists" exported data.
64  //
66 
67  //
68  // \brief Write the header for the "updated smart playlist" exported data.
69  // \param aMediaList The media list that has been updated.
70  //
71  nsresult WriteUpdatedSmartPlaylistHeader(sbIMediaList *aMediaList);
72 
73  //
74  // \brief Write the header for the "added media items" exported data.
75  // \param aMediaList The parent media list of the added media items.
76  // \param aIsMainLibrary Whether or not this list is the main library.
77  //
78  nsresult WriteAddedMediaItemsListHeader(sbIMediaList *aMediaList,
79  PRBool aIsMainLibrary = PR_FALSE);
80 
81  //
82  // \brief Write the header for the "updated media items" exported data.
83  //
85 
86  //
87  // \brief Write a added track out to the exported task file.
88  // \param aMediaItem The media item to write out to disk.
89  //
90  nsresult WriteAddedTrack(sbIMediaItem *aMediaItem);
91 
92  //
93  // \brief Write an updated track out to the exported task file.
94  // \param aMediaItem The media item to write out to disk.
95  //
96  nsresult WriteUpdatedTrack(sbIMediaItem *aMediaItem);
97 
98  //
99  // \brief Write a media list out to the exported task file.
100  // \param aMediaList The media list to write out to the task file.
101  //
102  nsresult WriteMediaListName(sbIMediaList *aMediaList);
103 
104  //
105  // \brief Write a string out to the exported task file, after URL-escaping it.
106  // \param aString The string to write out to the task file.
107  //
108  nsresult WriteEscapedString(const nsAString & aString);
109 
110 private:
111  nsString mTaskFilepath;
112  PRUint32 mCurOutputIndex;
113  std::ofstream mOutputStream;
114  nsCOMPtr<nsINetUtil> mNetUtil;
115 };
116 
117 #endif // sbMediaExportTaskWriter_h_
118 
nsresult WriteAddedMediaItemsListHeader(sbIMediaList *aMediaList, PRBool aIsMainLibrary=PR_FALSE)
NS_DECL_ISUPPORTS nsresult Init()
nsresult WriteUpdatedSmartPlaylistHeader(sbIMediaList *aMediaList)
A brief description of the contents of this interface.
nsresult WriteMediaListName(sbIMediaList *aMediaList)
nsresult WriteUpdatedTrack(sbIMediaItem *aMediaItem)
nsresult WriteEscapedString(const nsAString &aString)
Interface that defines a single item of media in the system.
nsresult WriteAddedTrack(sbIMediaItem *aMediaItem)