engine/src/ShowEngine.cpp
changeset 34 a6046405f1aa
parent 30 7bca37ba5fa9
child 36 e010fc411ddc
equal deleted inserted replaced
33:64ed1227e68d 34:a6046405f1aa
  1169 	DP("CShowEngine::DownloadNextShowL BEGIN");
  1169 	DP("CShowEngine::DownloadNextShowL BEGIN");
  1170 	// Check if we have anything in the download queue
  1170 	// Check if we have anything in the download queue
  1171 	const TInt count = DBGetDownloadsCount();
  1171 	const TInt count = DBGetDownloadsCount();
  1172 	DP("CShowEngine::DownloadNextShow\tTrying to start new download");DP1("CShowEngine::DownloadNextShow\tShows in download queue %d", count);
  1172 	DP("CShowEngine::DownloadNextShow\tTrying to start new download");DP1("CShowEngine::DownloadNextShow\tShows in download queue %d", count);
  1173 
  1173 
  1174 	// Inform the observers
       
  1175 	NotifyDownloadQueueUpdatedL();
       
  1176 
       
  1177 	if (count > 0)
  1174 	if (count > 0)
  1178 		{
  1175 		{
  1179 		if (iPodcastModel.SettingsEngine().DownloadSuspended())
  1176 		if (iPodcastModel.SettingsEngine().DownloadSuspended())
  1180 			{
  1177 			{
  1181 			DP("CShowEngine::DownloadNextShow\tDownload process is suspended, ABORTING");
  1178 			DP("CShowEngine::DownloadNextShow\tDownload process is suspended, ABORTING");
       
  1179 			// Inform the observers
       
  1180 			NotifyDownloadQueueUpdatedL();
  1182 			return;
  1181 			return;
  1183 			}
  1182 			}
  1184 		else if (iShowClient->IsActive())
  1183 		else if (iShowClient->IsActive())
  1185 			{
  1184 			{
  1186 			DP("CShowEngine::DownloadNextShow\tDownload process is already active.");
  1185 			DP("CShowEngine::DownloadNextShow\tDownload process is already active.");
       
  1186 			// Inform the observers
       
  1187 			NotifyDownloadQueueUpdatedL();
  1187 			return;
  1188 			return;
  1188 			}
  1189 			}
  1189 		else
  1190 		else
  1190 			{
  1191 			{
  1191 
  1192 
  1199 				DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(info->Title()));
  1200 				DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(info->Title()));
  1200 				info->SetDownloadState(EDownloading);
  1201 				info->SetDownloadState(EDownloading);
  1201 				info->SetLastError(KErrNone);
  1202 				info->SetLastError(KErrNone);
  1202 				DBUpdateShow(*info);
  1203 				DBUpdateShow(*info);
  1203 				iShowDownloading = info;
  1204 				iShowDownloading = info;
       
  1205 				// Inform the observers
       
  1206 				// important to do this after we change download state
       
  1207 				NotifyDownloadQueueUpdatedL();
       
  1208 
  1204 				TRAPD(error,getOk = GetShowL(info));
  1209 				TRAPD(error,getOk = GetShowL(info));
  1205 				if (error != KErrNone || !getOk)
  1210 				if (error != KErrNone || !getOk)
  1206 					{
  1211 					{
  1207 					info->SetDownloadState(EFailedDownload);
  1212 					info->SetDownloadState(EFailedDownload);
  1208 					DBRemoveDownload(info->Uid());
  1213 					DBRemoveDownload(info->Uid());
  1222 				}
  1227 				}
  1223 			}
  1228 			}
  1224 		}
  1229 		}
  1225 	else
  1230 	else
  1226 		{
  1231 		{
       
  1232 		// Inform the observers
       
  1233 		NotifyDownloadQueueUpdatedL();
  1227 		iShowDownloading = NULL;DP("CShowEngine::DownloadNextShow\tNothing to download");
  1234 		iShowDownloading = NULL;DP("CShowEngine::DownloadNextShow\tNothing to download");
  1228 		}
  1235 		}
  1229 	DP("CShowEngine::DownloadNextShowL END");
  1236 	DP("CShowEngine::DownloadNextShowL END");
  1230 	}
  1237 	}
  1231 
  1238