sbIPDStatus.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4 //=BEGIN SONGBIRD GPL
5 //
6 // This file is part of the Songbird web player.
7 //
8 // Copyright(c) 2005-2011 POTI, Inc.
9 // http://www.songbirdnest.com
10 //
11 // This file may be licensed under the terms of of the
12 // GNU General Public License Version 2 (the GPL).
13 //
14 // Software distributed under the License is distributed
15 // on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either
16 // express or implied. See the GPL for the specific language
17 // governing rights and limitations.
18 //
19 // You should have received a copy of the GPL along with this
20 // program. If not, go to http://www.gnu.org/licenses/gpl.html
21 // or write to the Free Software Foundation, Inc.,
22 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 //=END SONGBIRD GPL
25 */
26 
27 #ifndef __SB_IPD_STATUS_H__
28 #define __SB_IPD_STATUS_H__
29 
30 //------------------------------------------------------------------------------
31 //------------------------------------------------------------------------------
32 //
33 // iPod device status services defs.
34 //
35 //------------------------------------------------------------------------------
36 //------------------------------------------------------------------------------
37 
43 //------------------------------------------------------------------------------
44 //
45 // iPod device status imported services.
46 //
47 //------------------------------------------------------------------------------
48 
49 // Local imports.
50 #include "sbIPDUtils.h"
51 
52 // Songbird imports.
53 #include <sbIDeviceStatus.h>
54 #include <sbBaseDevice.h>
55 
56 // Mozilla imports.
57 #include <nsAutoPtr.h>
58 #include <nsStringAPI.h>
59 
60 // Libgpod imports.
61 #include <itdb.h>
62 
63 
64 //------------------------------------------------------------------------------
65 //
66 // iPod device status services classes.
67 //
68 //------------------------------------------------------------------------------
69 
70 // Forward declarations
71 class sbIPDDevice;
72 
78 {
79  //----------------------------------------------------------------------------
80  //
81  // Public interface.
82  //
83  //----------------------------------------------------------------------------
84 
85 public:
86 
87  //
88  // Operation types.
89  //
90  // OPERATION_TYPE_NONE No operation type defined.
91  // OPERATION_TYPE_MOUNT Mount operation.
92  // OPERATION_TYPE_WRITE Write operation.
93  // OPERATION_TYPE_DELETE Delete operation.
94  //
95 
96  static const PRUint32 OPERATION_TYPE_NONE = 0;
97  static const PRUint32 OPERATION_TYPE_MOUNT = 1;
98  static const PRUint32 OPERATION_TYPE_WRITE = 2;
99  static const PRUint32 OPERATION_TYPE_DELETE = 3;
100 
101 
102  //
103  // Constructors/destructors/initializers/finalizers.
104  //
105 
106  sbIPDStatus(sbIPDDevice* aDevice);
107 
108  virtual ~sbIPDStatus();
109 
110  nsresult Initialize();
111 
112  void Finalize();
113 
114 
115  //
116  // Operation services.
117  //
118 
119  void OperationStart(PRUint32 aOperationType,
121  PRUint32 aBatchCount);
122 
123  void OperationComplete(nsresult aResult);
124 
125 
126  //
127  // Item services.
128  //
129 
130  void ItemStart(PRInt32 aItemNum = -1,
131  PRInt32 aItemCount = -1);
132 
133  void ItemStart(Itdb_Track* aTrack,
134  PRInt32 aItemNum = -1,
135  PRInt32 aItemCount = -1);
136 
137  void ItemStart(Itdb_Playlist* aPlaylist,
138  Itdb_Track* aTrack,
139  PRInt32 aItemNum = -1,
140  PRInt32 aItemCount = -1);
141 
142  void ItemStart(sbIMediaList* aMediaList,
143  sbIMediaItem* aMediaItem,
144  PRInt32 aItemNum = -1,
145  PRInt32 aItemCount = -1);
146 
147  void ItemProgress(double aProgress);
148 
149  void ItemComplete(nsresult aResult);
150 
151  // Get the current sbIDeviceStatus
152  nsresult GetCurrentStatus(sbIDeviceStatus * *aCurrentStatus);
153 
154 
155  //
156  // iPod status services
157  //
158  nsresult ChangeStatus(PRUint32 newState);
159  nsresult UpdateStatus(PRUint32 forState,
160  const nsAString& currentOperation,
161  const nsAString& currentStateMessage,
162  PRInt32 currentIndex,
163  PRInt32 totalCount,
164  double currentProgress);
165 
166  void Idle();
167  //----------------------------------------------------------------------------
168  //
169  // Private interface.
170  //
171  //----------------------------------------------------------------------------
172 
173 private:
174 
175  //
176  // Internal services fields.
177  //
178  // mDevice Device object.
179  // mStatus Base device status object.
180  // mOperationType Current operation type.
181  // mMediaList Current operation media list.
182  // mMediaItem Current operation media item.
183  //
184 
185  sbIPDDevice* mDevice;
186  nsCOMPtr<sbIDeviceStatus> mStatus;
187  PRUint32 mOperationType;
188  nsCOMPtr<sbIMediaList> mMediaList;
189  nsCOMPtr<sbIMediaItem> mMediaItem;
190 };
191 
192 
205 SB_AUTO_CLASS(sbAutoStatusOperationFailure,
206  sbIPDStatus*,
207  mValue,
208  mValue->OperationComplete(NS_ERROR_FAILURE),
209  mValue = nsnull);
210 SB_AUTO_CLASS2(sbAutoStatusOperationComplete,
211  sbIPDStatus*,
212  nsresult,
213  mValue,
214  mValue->OperationComplete(mValue2),
215  mValue = nsnull);
216 SB_AUTO_CLASS(sbAutoStatusItemFailure,
217  sbIPDStatus*,
218  mValue,
219  mValue->ItemComplete(NS_ERROR_FAILURE),
220  mValue = nsnull);
221 
222 
223 #endif // __SB_IPD_STATUS_H__
224 
void OperationComplete(nsresult aResult)
Songbird iPod Device Utility Definitions.
virtual ~sbIPDStatus()
Definition: sbIPDStatus.cpp:98
void ItemComplete(nsresult aResult)
nsresult GetCurrentStatus(sbIDeviceStatus **aCurrentStatus)
nsresult ChangeStatus(PRUint32 newState)
void ItemStart(PRInt32 aItemNum=-1, PRInt32 aItemCount=-1)
A brief description of the contents of this interface.
SB_AUTO_CLASS(sbAutoStatusOperationFailure, sbIPDStatus *, mValue, mValue->OperationComplete(NS_ERROR_FAILURE), mValue=nsnull)
void Finalize()
sbIPDStatus(sbIPDDevice *aDevice)
Definition: sbIPDStatus.cpp:83
static const PRUint32 OPERATION_TYPE_DELETE
Definition: sbIPDStatus.h:99
nsresult UpdateStatus(PRUint32 forState, const nsAString &currentOperation, const nsAString &currentStateMessage, PRInt32 currentIndex, PRInt32 totalCount, double currentProgress)
void ItemProgress(double aProgress)
Interface that defines a single item of media in the system.
static const PRUint32 OPERATION_TYPE_MOUNT
Definition: sbIPDStatus.h:97
SB_AUTO_CLASS2(sbAutoStatusOperationComplete, sbIPDStatus *, nsresult, mValue, mValue->OperationComplete(mValue2), mValue=nsnull)
static const PRUint32 OPERATION_TYPE_WRITE
Definition: sbIPDStatus.h:98
void OperationStart(PRUint32 aOperationType, sbBaseDevice::TransferRequest *aRequest, PRUint32 aBatchCount)
nsresult Initialize()
static const PRUint32 OPERATION_TYPE_NONE
Definition: sbIPDStatus.h:96