private static void Scan(IList <BrowserScanResult> results) { for (int i = 0; i < browsers.Count; ++i) { IBrowser browser = browsers[i]; List <ScanResult> scans = new List <ScanResult>(); if (browser.Scan(scans)) { foreach (ScanResult scan in scans) { results.Add(new BrowserScanResult(browser, scan)); } } } if (results.Count > 0) { for (int i = 0; i < results.Count; ++i) { BrowserScanResult result = results[i]; Console.WriteLine(string.Format("{0}. {1} ({2})", i, result.scan.path, result.browser.name)); } } else { Console.WriteLine("Nothing found"); } }
private static bool GetLogins(BrowserScanResult scanResult, out IList <ILogins> results) { string path = scanResult.scan.path; IBrowser browser = scanResult.browser; results = browser.Get(path); return(results != null); }
private static bool CopyLogins(BrowserScanResult srcScanResult, BrowserScanResult destScanResult, IList <ILogins> srcLogins, out int skipped, out int copied, out int failed) { IBrowser srcBrowser = srcScanResult.browser; string srcEncryptedKey = srcScanResult.scan.encryptedKey; string destPath = destScanResult.scan.path; IBrowser destBrowser = destScanResult.browser; string destEncrpytedKey = destScanResult.scan.encryptedKey; IList <ILogins> logins = destBrowser.Get(destPath); if (logins == null) { skipped = 0; copied = 0; failed = 0; return(false); } IList <ILogins> loginsToAdd = new List <ILogins>(); skipped = 0; failed = 0; for (int i = 0; i < srcLogins.Count; ++i) { ILogins srcLogin = srcLogins[i]; if (CheckLoginsExists(logins, srcLogin)) { skipped++; continue; } else { ILogins destLogin = BrowserHelper.Copy <ILogins>(srcLogin, srcBrowser, srcEncryptedKey, destBrowser, destEncrpytedKey); if (destLogin == null) { failed++; continue; } loginsToAdd.Add(destLogin); } } if (loginsToAdd.Count == 0) { copied = 0; return(true); } copied = destBrowser.Insert(destPath, loginsToAdd, (cur, total) => { Console.WriteLine(string.Format("Copying {0} of {1} ", cur, total)); Console.SetCursorPosition(Console.CursorLeft, Console.CursorTop - 1); }); return(true); }
private static void Copy(int srcIndex, int destIndex, IList <BrowserScanResult> results) { if (srcIndex == destIndex) { Console.WriteLine("Can't copy to same destination"); return; } BrowserScanResult srcScanResult = results[srcIndex]; if (!GetLogins(srcScanResult, out IList <ILogins> srcLogins)) { return; } BrowserScanResult descScanResult = results[destIndex]; if (!CopyLogins(srcScanResult, descScanResult, srcLogins, out int srcSkipped, out int srcCopied, out int srcFailed)) { return; } Console.WriteLine(string.Format("Copied {0} of {1} logins. Skipped {2} logins, failed {3} logins", srcCopied, srcLogins.Count - srcSkipped - srcFailed, srcSkipped, srcFailed)); }