29 #include <nsThreadUtils.h>
40 mCancelRequested(PR_FALSE),
55 nsresult rv = UpdateProgress();
56 NS_ENSURE_SUCCESS(rv, rv);
63 mStatusText = aStatusText;
65 nsresult rv = UpdateProgress();
66 NS_ENSURE_SUCCESS(rv, rv);
73 mTitleText = aTitleText;
75 nsresult rv = UpdateProgress();
76 NS_ENSURE_SUCCESS(rv, rv);
83 mProgress = aProgress;
85 nsresult rv = UpdateProgress();
86 NS_ENSURE_SUCCESS(rv, rv);
95 nsresult rv = UpdateProgress();
96 NS_ENSURE_SUCCESS(rv, rv);
103 mErrorMessages.AppendElement(aErrorMessage);
105 nsresult rv = UpdateProgress();
106 NS_ENSURE_SUCCESS(rv, rv);
112 sbiTunesImporterJob::GetStatus(PRUint16 *aStatus)
119 sbiTunesImporterJob::GetBlocked(PRBool *aBlocked)
121 NS_ENSURE_ARG_POINTER(aBlocked);
122 *aBlocked = PR_FALSE;
128 sbiTunesImporterJob::GetStatusText(nsAString & aStatusText)
130 aStatusText = mStatusText;
136 sbiTunesImporterJob::GetTitleText(nsAString & aTitleText)
138 aTitleText = mTitleText;
144 sbiTunesImporterJob::GetProgress(PRUint32 *aProgress)
146 *aProgress = mProgress;
152 sbiTunesImporterJob::GetTotal(PRUint32 *aTotal)
160 sbiTunesImporterJob::GetErrorCount(PRUint32 *aErrorCount)
162 *aErrorCount = mErrorMessages.Length();
175 NS_ENSURE_TRUE(*aEnumerator, NS_ERROR_OUT_OF_MEMORY);
176 NS_ADDREF(*aEnumerator);
184 if (mListeners.IndexOfObject(aListener) == -1) {
185 PRBool
const inserted = mListeners.AppendObject(aListener);
186 NS_ENSURE_TRUE(inserted, NS_ERROR_OUT_OF_MEMORY);
189 NS_WARNING(
"sbiTunesImporterJob::AddJobProgressListener listener already added");
198 PRInt32 index = mListeners.IndexOfObject(aListener);
199 mListeners.RemoveObjectAt(index);
204 sbiTunesImporterJob::GetCanCancel(PRBool *aCanCancel)
206 *aCanCancel = mCanCancel;
212 sbiTunesImporterJob::Cancel()
214 mCancelRequested = PR_TRUE;
219 sbiTunesImporterJob::UpdateProgress() {
220 PRUint32
const listenerCount = mListeners.Count();
221 for (PRUint32 index = 0; index < listenerCount; ++index) {
223 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"iTunes Import listener reported error");
virtual ~sbiTunesImporterJob()
NS_IMPL_THREADSAFE_ISUPPORTS2(sbiTunesImporterJob, sbIJobProgress, sbIJobCancelable) sbiTunesImporterJob
Generic interface for exposing long running jobs to the UI.
nsresult AddErrorMessage(nsAString const &aErrorMessage)
NS_DECL_ISUPPORTS static NS_DECL_NSISTRINGENUMERATOR sbTArrayStringEnumerator * New(const sbStringArray &aStringArray)
nsresult SetStatusText(nsAString const &aStatusText)
NS_DECL_ISUPPORTS NS_DECL_SBIJOBPROGRESS static NS_DECL_SBIJOBCANCELABLE sbiTunesImporterJob * New()
nsresult SetStatus(PRUint32 aStatus)
nsresult SetTitleText(nsAString const &aTitleText)
Implemented to receive notifications from sbIJobProgress interfaces.
nsresult SetProgress(PRUint32 aProgress)
#define SB_UNUSED_IN_RELEASE(decl)
nsresult SetTotal(PRUint32 aTotal)