This repository was archived by the owner on Aug 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathProgram.cs
More file actions
166 lines (138 loc) · 6.76 KB
/
Program.cs
File metadata and controls
166 lines (138 loc) · 6.76 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
Technitium Bit Chat
Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using TechnitiumLibrary.Security.Cryptography;
namespace BitChatApp
{
static class Program
{
#region variables
public const string MUTEX_NAME = "BitChatApp";
public readonly static Uri SIGNUP_URI = new Uri("https://bitchat.im/api/signup.aspx");
public readonly static Uri UPDATE_URI = new Uri("https://bitchat.im/download/linux/update.bin");
public const int UPDATE_CHECK_INTERVAL_DAYS = 1;
static string _rootCert = @"
Q0UBAQpUQ0EtMjAxNC0xQ1AB7wMAAM8DAAAgVGVjaG5pdGl1bSBDZXJ0aWZpY2F0ZSBBdXRob3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MVUpNSExwcU5IYmpqdXdBWHFyZXJ2aVl4NHNR
Z0QzZUJLaGt0K3VTUzRnUXM9PC9Nb2R1bHVzPjxFeHBvbmVudD5BUUFCPC9FeHBvbmVudD48L1JT
QUtleVZhbHVlPiNodHRwczovL3RlY2huaXRpdW0uY29tL2NybC9jcmwuYXNweAFTTgEAAn/m6RMT
OVhQ7xyyc8NwVWbs+jA6cnPpks+yL6j+Di3BEcmT9HlDRIGVz8wBlI0qEtsJ1OsY7blYkJM8qm6s
qK4IlC6JxwzMgDQouaj7yPoMvZiHKNZnn0ikQTHln5IVgBjjnSRTpvzKpnhpRl069xB5kWLTJqIS
ozTnoccrn2pCrVPqhwcJHDZf7IBHlVn7VOfiBHm73yBDpSBvYWtkl+qojPL1P0RVtT+dhEG3HJF+
2gfLC3kXGtLyQSuOtjEsU38pSMr2/2DnOXan/5KDUEOUrW3gQ2BWKv4HK7RqLOZqUSigQIu2a5qV
w5W5oJrk7Dr2Uou0KLGaV1BofdGSKTem5Kz4gsSC3zwP8kjPmqETA7RkAPs8nL+kTi/20j5BWgIx
S2QVWrwjV4k4urVu91pyjY5P7JJOO3SN85TOQ9wdeVv0lthdd4cED7HFE+trqyfCeZD4BMKihXsZ
BF+Xh/PhxxJjLoHwsphPF7qGaltcAEYrK88zS0c1KOPdJQsbjqSJerwMT5al/OYSp7FPXn3POo+s
xN9SGwJcanbJC8cP02Bq3bxTW+GHXU+dEr1LY2eBXej5lB2RFs8gJ5uP8cmjzwWMX/Ib6aNIs6IM
4d1HijZ3z5iokvPkmO8qwYt0lSSysexs/fY9JLTmyJX4ww10amMLAg7qfYbN33Wv5qplBlNIQTI1
NgEA
";
public readonly static Certificate[] TRUSTED_CERTIFICATES;
static Mutex _app;
#endregion
#region public
static Program()
{
TRUSTED_CERTIFICATES = new Certificate[1];
using (MemoryStream mS = new MemoryStream(Convert.FromBase64String(_rootCert)))
{
TRUSTED_CERTIFICATES[0] = new Certificate(mS);
}
}
[STAThread]
public static void Main(string[] args)
{
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
#region check for multiple instances
bool createdNewMutex;
_app = new Mutex(true, MUTEX_NAME, out createdNewMutex);
if (!createdNewMutex)
{
MessageBox.Show("Bit Chat is already running. Please click on the Bit Chat icon to open the chat window.", "Bit Chat Already Running!", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
#endregion
#region profile manager
while (true)
{
frmProfileManager mgr = new frmProfileManager();
if (mgr.ShowDialog() == DialogResult.OK)
{
try
{
if (mgr.Profile != null)
{
bool loadMainForm = false;
if ((mgr.Profile.LocalCertificateStore.Certificate.Type == CertificateType.User) && (mgr.Profile.LocalCertificateStore.Certificate.Capability == CertificateCapability.UserAuthentication))
{
loadMainForm = true;
}
else
{
using (frmRegister frm = new frmRegister(mgr.Profile, mgr.ProfileFilePath, mgr.IsPortableApp, mgr.ProfileFolder, false))
{
loadMainForm = (frm.ShowDialog() == DialogResult.OK);
}
}
if (loadMainForm)
{
using (frmMain frm = new frmMain(mgr.Profile, mgr.ProfileFilePath, string.Join(" ", args)))
{
Application.Run(frm);
if (frm.DialogResult != DialogResult.Ignore)
break;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error! " + ex.Message, "Error - Bit Chat Profile Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
break;
}
}
#endregion
}
catch (Exception ex)
{
MessageBox.Show("Error! " + ex.Message + "\r\n\r\nClick OK to quit the application.", "Error - Bit Chat", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
}
}