28 #include <nsIFileURL.h>
31 #include <sbIMediaItem.h>
32 #include <sbITranscodeManager.h>
34 #include <nsComponentManagerUtils.h>
35 #include <nsNetUtil.h>
36 #include <nsServiceManagerUtils.h>
55 sbTranscodeError::~sbTranscodeError()
58 nsAutoLock::DestroyLock(
mLock);
67 sbTranscodeError::GetMessageMoz(PRUnichar * *aMessage)
69 NS_ENSURE_ARG_POINTER(aMessage);
71 nsresult rv = GetData(message);
72 NS_ENSURE_SUCCESS(rv, rv);
73 *aMessage = ToNewUnicode(message);
74 NS_ENSURE_TRUE(*aMessage, NS_ERROR_OUT_OF_MEMORY);
81 sbTranscodeError::GetErrorMessage(nsAString & aErrorMessage)
84 nsresult rv = GetData(aErrorMessage);
85 NS_ENSURE_SUCCESS(rv, rv);
91 sbTranscodeError::GetSourceName(nsAString & aSourceName)
99 sbTranscodeError::GetSourceLine(nsAString & aSourceLine)
101 return GetDetail(aSourceLine);
106 sbTranscodeError::GetLineNumber(PRUint32 *aLineNumber)
108 NS_ENSURE_ARG_POINTER(aLineNumber);
115 sbTranscodeError::GetColumnNumber(PRUint32 *aColumnNumber)
117 NS_ENSURE_ARG_POINTER(aColumnNumber);
124 sbTranscodeError::GetFlags(PRUint32 *aFlags)
126 NS_ENSURE_ARG_POINTER(aFlags);
127 *aFlags = nsIScriptError::errorFlag;
133 sbTranscodeError::GetCategory(
char * *aCategory)
135 NS_ENSURE_ARG_POINTER(aCategory);
136 *aCategory = ToNewCString(NS_LITERAL_CSTRING(
"songbird transcode"));
149 const PRUnichar *sourceName,
150 const PRUnichar *sourceLine,
152 PRUint32 columnNumber,
154 const char *category)
157 return NS_ERROR_NOT_IMPLEMENTED;
165 nsresult rv = GetData(result);
166 NS_ENSURE_SUCCESS(rv, rv);
167 CopyUTF16toUTF8(result, _retval);
174 sbTranscodeError::GetData(nsAString &
aData)
178 nsCOMPtr<nsIURI>
uri;
179 nsCOMPtr<sbIMediaItem> item;
182 nsAutoLock lock(
mLock);
192 NS_ENSURE_SUCCESS(rv, rv);
193 CompressWhitespace(title);
194 if (!title.IsEmpty()) {
199 if (title.IsEmpty() && !spec.IsEmpty()) {
200 rv = NS_NewURI(getter_AddRefs(uri), spec);
201 NS_ENSURE_SUCCESS(rv, rv);
202 nsCOMPtr<nsIFileURL> fileUrl = do_QueryInterface(uri, &rv);
203 if (NS_SUCCEEDED(rv) && fileUrl) {
204 nsCOMPtr<nsIFile>
file;
205 rv = fileUrl->GetFile(getter_AddRefs(file));
206 NS_ENSURE_SUCCESS(rv, rv);
207 rv = file->GetPath(title);
208 NS_ENSURE_SUCCESS(rv, rv);
215 if (title.IsEmpty()) {
220 NS_NAMED_LITERAL_STRING(REPLACE_KEY,
"%(item)");
221 PRInt32 index = aData.Find(REPLACE_KEY);
223 aData.Replace(index, REPLACE_KEY.Length(), title);
228 sbTranscodeError::SetData(
const nsAString & aData)
231 return NS_ERROR_NOT_IMPLEMENTED;
238 NS_ENSURE_ARG_POINTER(_retval);
240 nsresult rv = GetData(message);
241 NS_ENSURE_SUCCESS(rv, rv);
242 *_retval = ToNewUnicode(message);
243 NS_ENSURE_TRUE(*_retval, NS_ERROR_OUT_OF_MEMORY);
251 sbTranscodeError::GetType(PRUint16 *aType)
253 NS_ENSURE_ARG_POINTER(aType);
254 *aType = nsISupportsPrimitive::TYPE_STRING;
262 sbTranscodeError::GetMessageWithItem(nsAString & aMessageWithItem)
264 nsAutoLock lock(
mLock);
271 sbTranscodeError::GetMessageWithoutItem(nsAString & aMessageWithoutItem)
273 nsAutoLock lock(
mLock);
280 sbTranscodeError::GetDetail(nsAString & aDetails)
282 nsAutoLock lock(
mLock);
289 sbTranscodeError::GetSourceUri(nsAString & aSourceUri)
291 nsAutoLock lock(
mLock);
296 sbTranscodeError::SetSourceUri(
const nsAString & aSourceUri)
298 nsAutoLock lock(
mLock);
305 sbTranscodeError::GetSourceItem(
sbIMediaItem * *aSourceItem)
307 NS_ENSURE_ARG_POINTER(aSourceItem);
308 nsAutoLock lock(
mLock);
309 NS_IF_ADDREF(*aSourceItem =
mSrcItem);
313 sbTranscodeError::SetSourceItem(
sbIMediaItem * aSourceItem)
315 nsAutoLock lock(
mLock);
322 sbTranscodeError::GetDestUri(nsAString & aDestUri)
324 nsAutoLock lock(
mLock);
329 sbTranscodeError::SetDestUri(
const nsAString & aDestUri)
331 nsAutoLock lock(
mLock);
338 sbTranscodeError::GetDestItem(
sbIMediaItem * *aDestItem)
340 NS_ENSURE_ARG_POINTER(aDestItem);
341 nsAutoLock lock(
mLock);
348 nsAutoLock lock(
mLock);
359 const nsAString & aMessageWithoutItem,
360 const nsAString & aDetails)
362 NS_ENSURE_FALSE(
mLock, NS_ERROR_ALREADY_INITIALIZED);
363 mLock = nsAutoLock::NewLock(
"sbTranscodeError::mLock");
364 NS_ENSURE_TRUE(
mLock, NS_ERROR_OUT_OF_MEMORY);
365 nsAutoLock lock(
mLock);
nsString mMessageWithItem
sbDeviceFirmwareAutoCheckForUpdate prototype flags
NS_IMPL_THREADSAFE_ISUPPORTS5(sbTranscodeError, sbITranscodeError, nsIScriptError, nsIConsoleMessage, nsISupportsString, nsISupportsPrimitive) sbTranscodeError
nsString mMessageWithoutItem
static nsresult ToString(const nsDiscriminatedUnion &data, nsACString &outString)
nsCOMPtr< sbIMediaItem > mDestItem
nsCOMPtr< sbIMediaItem > mSrcItem
#define SB_PROPERTY_TRACKNAME
_updateTextAndScrollDataForFrame aData