forked from KSP-CKAN/CKAN-GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainRepo.cs
More file actions
87 lines (69 loc) · 2.48 KB
/
MainRepo.cs
File metadata and controls
87 lines (69 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.ComponentModel;
using System.Net;
using System.Windows.Forms;
using Newtonsoft.Json;
namespace CKAN
{
public struct RepositoryList
{
public Repository[] repositories;
}
public partial class Main
{
private BackgroundWorker m_UpdateRepoWorker;
public static RepositoryList FetchMasterRepositoryList(Uri master_uri = null)
{
WebClient client = new WebClient();
if (master_uri == null)
{
master_uri = Repository.default_repo_master_list;
}
string json = client.DownloadString(master_uri);
return JsonConvert.DeserializeObject<RepositoryList>(json);
}
public void UpdateRepo()
{
m_User.displayYesNo = YesNoDialog;
m_TabController.RenameTab("WaitTabPage", "Updating repositories");
CurrentInstance.ScanGameData();
m_UpdateRepoWorker.RunWorkerAsync();
Util.Invoke(this, () => Enabled = false);
SetDescription("Contacting repository..");
ClearLog();
ShowWaitDialog();
}
private void UpdateRepo(object sender, DoWorkEventArgs e)
{
try
{
KSP current_instance1 = CurrentInstance;
Repo.UpdateAllRepositories(RegistryManager.Instance(CurrentInstance), current_instance1, GUI.user);
}
catch (UriFormatException ex)
{
m_ErrorDialog.ShowErrorDialog(ex.Message);
}
catch (MissingCertificateKraken ex)
{
m_ErrorDialog.ShowErrorDialog(ex.ToString());
}
catch (Exception ex)
{
m_ErrorDialog.ShowErrorDialog("Failed to connect to repository. Exception: " + ex.Message);
}
m_User.displayYesNo = null;
}
private void PostUpdateRepo(object sender, RunWorkerCompletedEventArgs e)
{
SetDescription("Scanning for manually installed mods");
CurrentInstance.ScanGameData();
UpdateModsList(repo_updated: true);
HideWaitDialog(true);
AddStatusMessage("Repository successfully updated");
Util.Invoke(ModList, () => ModList.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells));
Util.Invoke(this, () => Enabled = true);
Util.Invoke(this, RecreateDialogs);
}
}
}