49 #include "sbIIPDDeviceEvent.h"
57 #include <nsComponentManagerUtils.h>
58 #include <nsILocalFile.h>
76 sbIPDDevice::FPConnect()
81 nsAutoMonitor autoRequestLock(mDBLock);
85 NS_ENSURE_SUCCESS(rv, rv);
100 sbIPDDevice::FPDisconnect()
103 nsAutoMonitor autoRequestLock(mDBLock);
106 mFPUserIDList.Clear();
119 sbIPDDevice::FPCheckTrackAuth(Itdb_Track* aTrack)
122 NS_ASSERTION(aTrack,
"aTrack is null");
132 PRUint32 userID = aTrack->drm_userid;
135 PRBool authorized = PR_FALSE;
136 for (PRUint32
i = 0;
i < mFPUserIDList.Length();
i++) {
137 if (mFPUserIDList[
i] == userID) {
138 authorized = PR_TRUE;
147 nsAutoString accountName;
148 nsAutoString userName;
149 rv = FPGetTrackAuthInfo(aTrack, &userID, accountName, userName);
150 NS_ENSURE_SUCCESS(rv, rv);
153 nsCOMPtr<sbIMediaItem> mediaItem;
157 getter_AddRefs(mediaItem));
158 NS_ENSURE_SUCCESS(rv, rv);
161 FIELD_LOG((
"Track not authorized 0x%08x %s %s\n",
163 NS_ConvertUTF16toUTF8(accountName).
get(),
164 NS_ConvertUTF16toUTF8(userName).
get()));
167 CreateAndDispatchFairPlayEvent
189 sbIPDDevice::FPSetupTrackInfo(nsIFile* aTrackFile,
193 NS_ASSERTION(aTrackFile,
"aTrackFile is null");
194 NS_ASSERTION(aTrack,
"aTrack is null");
200 nsAutoString fileName;
201 nsAutoString fileExt;
202 rv = aTrackFile->GetLeafName(fileName);
203 NS_ENSURE_SUCCESS(rv, rv);
204 fileExt.Assign(StringTail(fileName, 3));
207 if (!fileExt.Equals(NS_LITERAL_STRING(
"m4p")))
212 NS_ENSURE_TRUE(atomReader, NS_ERROR_OUT_OF_MEMORY);
213 sbAutoQTAtomReader autoAtomReader(atomReader);
214 rv = atomReader->
Open(aTrackFile);
215 NS_ENSURE_SUCCESS(rv, rv);
220 NS_ENSURE_SUCCESS(rv, rv);
223 aTrack->drm_userid = userID;
224 aTrack->unk148 = 0x01010100;
225 aTrack->filetype = g_strdup(
"Protected AAC audio file");
248 sbIPDDevice::FPGetKeyInfo()
253 nsCOMPtr<nsILocalFile>
254 iEKInfoFile = do_CreateInstance(
"@mozilla.org/file/local;1", &rv);
255 NS_ENSURE_SUCCESS(rv, rv);
256 rv = iEKInfoFile->InitWithPath(mMountPath);
257 NS_ENSURE_SUCCESS(rv, rv);
258 rv = iEKInfoFile->Append(NS_LITERAL_STRING(
"iPod_Control"));
259 NS_ENSURE_SUCCESS(rv, rv);
260 rv = iEKInfoFile->Append(NS_LITERAL_STRING(
"iTunes"));
261 NS_ENSURE_SUCCESS(rv, rv);
262 rv = iEKInfoFile->Append(NS_LITERAL_STRING(
"iEKInfo"));
263 NS_ENSURE_SUCCESS(rv, rv);
268 rv = iEKInfoFile->Exists(&exists);
269 NS_ENSURE_SUCCESS(rv, rv);
275 NS_ENSURE_TRUE(atomReader, NS_ERROR_OUT_OF_MEMORY);
276 sbAutoQTAtomReader autoAtomReader(atomReader);
277 rv = atomReader->
Open(iEKInfoFile);
278 NS_ENSURE_SUCCESS(rv, rv);
282 NS_ENSURE_SUCCESS(rv, rv);
299 sbIPDDevice::FPGetTrackAuthInfo(Itdb_Track* aTrack,
301 nsAString& aAccountName,
302 nsAString& aUserName)
305 NS_ASSERTION(aTrack,
"aTrack is null");
306 NS_ASSERTION(aUserID,
"aUserID is null");
312 gchar* trackFilePath = itdb_filename_on_ipod(aTrack);
313 NS_ENSURE_TRUE(trackFilePath, NS_ERROR_OUT_OF_MEMORY);
314 sbAutoGMemPtr autoTrackFilePath(trackFilePath);
317 nsCOMPtr<nsILocalFile>
318 trackFile = do_CreateInstance(
"@mozilla.org/file/local;1", &rv);
319 NS_ENSURE_SUCCESS(rv, rv);
320 rv = trackFile->InitWithPath(NS_ConvertUTF8toUTF16(trackFilePath));
321 NS_ENSURE_SUCCESS(rv, rv);
325 NS_ENSURE_TRUE(atomReader, NS_ERROR_OUT_OF_MEMORY);
326 sbAutoQTAtomReader autoAtomReader(atomReader);
327 rv = atomReader->
Open(trackFile);
328 NS_ENSURE_SUCCESS(rv, rv);
333 NS_ENSURE_SUCCESS(rv, rv);
static nsresult GetOriginMediaItemByDevicePersistentId(sbILibrary *aLibrary, const nsAString &aDevicePersistentId, sbIMediaItem **aItem)
const unsigned long EVENT_IPOD_FAIRPLAY_NOT_AUTHORIZED
nsresult GetFairPlayAccountName(nsAString &aAccountName)
nsresult GetFairPlayUserName(nsAString &aUserName)
nsresult Open(nsIFile *aFile)
Songbird iPod Device Definitions.
QuickTime Atom Reader Definitions.
nsresult GetIEKInfoUserIDs(nsTArray< PRUint32 > &aUserIDList)
Songbird iPod Device Logging Definitions.
_getSelectedPageStyle s i
nsresult GetFairPlayUserID(PRUint32 *aUserID)