public void refreshTorrents(bool compare = false)
{
_appSettings = getSettings ();
if (_appSettings == null)
return;
if (string.IsNullOrEmpty(_appSettings.SettingsList[0].host) || string.IsNullOrEmpty(_appSettings.SettingsList[0].port.ToString()))
return;
var client = new DelugeClient (_appSettings.SettingsList[0].host, _appSettings.SettingsList[0].port);
client.Login (_appSettings.SettingsList[0].pass);
var torrents = client.GetTorrents ();
var sortedTorrents = torrents.OrderBy(c => c.TrackerHost).ThenBy(c => c.TimeAdded);
if (compare && curTorrents != null) {
IEnumerable<CodeRinseRepeat.Deluge.Torrent> differenceQuery =
sortedTorrents.Except(curTorrents);
//Console.WriteLine ("Difference: " + differenceQuery.Count<CodeRinseRepeat.Deluge.Torrent>().ToString());
if (differenceQuery.Count<CodeRinseRepeat.Deluge.Torrent> () > 0) {
UILocalNotification notification = new UILocalNotification ();
notification.FireDate = DateTime.Now;
notification.AlertBody = "DelugeMobile: New torrents added!";
UIApplication.SharedApplication.ScheduleLocalNotification (notification);
}
}
didRefreshData = true;
curTorrents = sortedTorrents;
// Save torrents to XML
SaveTorrents ();
}