private void ApplyUpdate(object aUpdateArgs) { lock (iLock) { if (iDisposed) { return; } } HandleChanged(string.Empty, 0); UpdateArgs args = aUpdateArgs as UpdateArgs; try { string filename = FlashSupport.GetRomFilename(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()), args.Filename as string, iVariant); UserLog.WriteLine("Updating software on " + MacAddress + " with " + filename); if (filename != null) { IPAddress adapter = null; lock (iLock) { adapter = iAdapterAddress; } if (adapter != null) { new FlashSupport.Reprogrammer(adapter, iUglyname, filename, args.Recovery, HandleChanged); } else { HandleChanged("Software Update Failed", 100); } } } catch (FlashSupport.GetRomFilenameFailed e) { HandleChanged("Software Update Failed (" + e.Message + ")", 100); } iDevice.Updating = false; iUpdateListener.SetUpdating(false); }
public string XmlFilename(Firmware aFirmware, FirmwareRetriever.DDownloadProgress aProgress) { iEventCacheClear.WaitOne(); bool cached = false; bool found = false; FirmwareRetriever retriever = null; lock (iLock) { if (IsCached(aFirmware)) { cached = true; aProgress(100); } if (!cached) { foreach (FirmwareRetriever r in iRetrieverList) { if (r.Uri == aFirmware.Uri) { retriever = r; found = true; break; } } if (!found) { retriever = new FirmwareRetriever(aFirmware.Uri, iCachePath); iRetrieverList.Add(retriever); } } } if (!cached) { if (found) { retriever.WaitOne(aProgress); } else { bool downloaded = retriever.Download(aProgress); lock (iLock) { if (iRetrieverList.Remove(retriever)) { retriever.Dispose(); } } if (!downloaded) { return(null); } } } lock (iLock) { string filename = FlashSupport.GetRomFilename(iCachePathTemp, Path.Combine(iCachePath, Path.GetFileName(aFirmware.Uri.AbsolutePath)), aFirmware.Variant); if (string.IsNullOrEmpty(filename)) { File.Delete(Path.Combine(iCachePath, Path.GetFileName(aFirmware.Uri.AbsolutePath))); } return(filename); } }