@@ -56,7 +56,10 @@ public class ACTWebSocketMain : UserControl, IActPluginV1, PluginDirectory
5656 private Button buttonOverlay ;
5757 private ProgressBar progressBar ;
5858 private Button buttonDownload ;
59- private CheckBox SSLUse ;
59+ private GroupBox groupBox4 ;
60+ private Button buttonCopyCode ;
61+ private Label label1 ;
62+ private TextBox hashCode ;
6063 private CheckBox chatFilter ;
6164
6265 public void SetSkinDir ( string path )
@@ -163,14 +166,18 @@ private void InitializeComponent()
163166 this . groupBox3 = new System . Windows . Forms . GroupBox ( ) ;
164167 this . FileSkinListView = new System . Windows . Forms . ListView ( ) ;
165168 this . Title = ( ( System . Windows . Forms . ColumnHeader ) ( new System . Windows . Forms . ColumnHeader ( ) ) ) ;
166- this . SSLUse = new System . Windows . Forms . CheckBox ( ) ;
169+ this . groupBox4 = new System . Windows . Forms . GroupBox ( ) ;
170+ this . buttonCopyCode = new System . Windows . Forms . Button ( ) ;
171+ this . label1 = new System . Windows . Forms . Label ( ) ;
172+ this . hashCode = new System . Windows . Forms . TextBox ( ) ;
167173 this . startoption . SuspendLayout ( ) ;
168174 this . hostdata . SuspendLayout ( ) ;
169175 this . othersets . SuspendLayout ( ) ;
170176 this . serverStatus . SuspendLayout ( ) ;
171177 this . groupBox2 . SuspendLayout ( ) ;
172178 this . groupBox1 . SuspendLayout ( ) ;
173179 this . groupBox3 . SuspendLayout ( ) ;
180+ this . groupBox4 . SuspendLayout ( ) ;
174181 this . SuspendLayout ( ) ;
175182 //
176183 // port
@@ -248,7 +255,6 @@ private void InitializeComponent()
248255 // startoption
249256 //
250257 this . startoption . BackColor = System . Drawing . Color . Transparent ;
251- this . startoption . Controls . Add ( this . SSLUse ) ;
252258 this . startoption . Controls . Add ( this . skinOnAct ) ;
253259 this . startoption . Controls . Add ( this . UPNPUse ) ;
254260 this . startoption . Controls . Add ( this . randomURL ) ;
@@ -472,17 +478,36 @@ private void InitializeComponent()
472478 //
473479 resources . ApplyResources ( this . Title , "Title" ) ;
474480 //
475- // SSLUse
481+ // groupBox4
476482 //
477- resources . ApplyResources ( this . SSLUse , "SSLUse" ) ;
478- this . SSLUse . BackColor = System . Drawing . Color . Transparent ;
479- this . SSLUse . Name = "SSLUse" ;
480- this . SSLUse . UseVisualStyleBackColor = false ;
481- this . SSLUse . CheckedChanged += new System . EventHandler ( this . SSLUse_CheckedChanged ) ;
483+ this . groupBox4 . Controls . Add ( this . buttonCopyCode ) ;
484+ this . groupBox4 . Controls . Add ( this . label1 ) ;
485+ this . groupBox4 . Controls . Add ( this . hashCode ) ;
486+ resources . ApplyResources ( this . groupBox4 , "groupBox4" ) ;
487+ this . groupBox4 . Name = "groupBox4" ;
488+ this . groupBox4 . TabStop = false ;
489+ //
490+ // buttonCopyCode
491+ //
492+ resources . ApplyResources ( this . buttonCopyCode , "buttonCopyCode" ) ;
493+ this . buttonCopyCode . Name = "buttonCopyCode" ;
494+ this . buttonCopyCode . UseVisualStyleBackColor = true ;
495+ this . buttonCopyCode . Click += new System . EventHandler ( this . buttonCopyCode_Click ) ;
496+ //
497+ // label1
498+ //
499+ resources . ApplyResources ( this . label1 , "label1" ) ;
500+ this . label1 . Name = "label1" ;
501+ //
502+ // hashCode
503+ //
504+ resources . ApplyResources ( this . hashCode , "hashCode" ) ;
505+ this . hashCode . Name = "hashCode" ;
482506 //
483507 // ACTWebSocketMain
484508 //
485509 this . AutoScaleMode = System . Windows . Forms . AutoScaleMode . None ;
510+ this . Controls . Add ( this . groupBox4 ) ;
486511 this . Controls . Add ( this . groupBox3 ) ;
487512 this . Controls . Add ( this . groupBox2 ) ;
488513 this . Controls . Add ( this . groupBox1 ) ;
@@ -502,6 +527,8 @@ private void InitializeComponent()
502527 this . groupBox2 . ResumeLayout ( false ) ;
503528 this . groupBox1 . ResumeLayout ( false ) ;
504529 this . groupBox3 . ResumeLayout ( false ) ;
530+ this . groupBox4 . ResumeLayout ( false ) ;
531+ this . groupBox4 . PerformLayout ( ) ;
505532 this . ResumeLayout ( false ) ;
506533
507534 }
@@ -620,7 +647,7 @@ public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
620647 BeforeLogLineReadUse . Checked = BeforeLogLineRead ;
621648 OnLogLineReadUse . Checked = OnLogLineRead ;
622649 MiniParseUse . Checked = MiniParse ;
623- SSLUse . Checked = UseSSL ;
650+ // SSLUse.Checked = UseSSL;
624651 UPNPUse . Checked = UseUPnP ;
625652 randomURL . Checked = RandomURL ;
626653 skinOnAct . Checked = SkinOnAct ;
@@ -749,14 +776,14 @@ void LoadSettings()
749776 {
750777 UseUPnP = false ;
751778 }
752- if ( obj . TryGetValue ( "UseSSL" , out token ) )
753- {
754- UseSSL = token . ToObject < bool > ( ) ;
755- }
756- else
757- {
758- UseSSL = false ;
759- }
779+ // if (obj.TryGetValue("UseSSL", out token))
780+ // {
781+ // UseSSL = token.ToObject<bool>();
782+ // }
783+ // else
784+ // {
785+ // UseSSL = false;
786+ // }
760787 if ( obj . TryGetValue ( "SkinOnAct" , out token ) )
761788 {
762789 SkinOnAct = token . ToObject < bool > ( ) ;
@@ -840,7 +867,7 @@ void SaveSettings()
840867 obj . Add ( "Hostname" , Hostname ) ;
841868 obj . Add ( "RandomURL" , RandomURL ) ;
842869 obj . Add ( "UseUPnP" , UseUPnP ) ;
843- obj . Add ( "UseSSL" , UseSSL ) ;
870+ // obj.Add("UseSSL", UseSSL);
844871 obj . Add ( "AutoRun" , AutoRun ) ;
845872 obj . Add ( "AutoOverlay" , AutoOverlay ) ;
846873 obj . Add ( "BeforeLogLineRead" , BeforeLogLineRead ) ;
@@ -971,7 +998,7 @@ public bool RandomURL
971998 }
972999 }
9731000
974- public bool UseSSL { get ; set ; }
1001+ // public bool UseSSL { get; set; }
9751002 public bool UseUPnP { get ; set ; }
9761003 public bool AutoRun { get ; set ; }
9771004 public bool AutoOverlay { get ; set ; }
@@ -1032,11 +1059,11 @@ public void StartServer()
10321059 {
10331060 if ( UseUPnP )
10341061 {
1035- core . StartServer ( localhostOnly ? "127.0.0.1" : "0.0.0.0" , Port , UPnPPort , Hostname , SkinOnAct , UseSSL ) ;
1062+ core . StartServer ( localhostOnly ? "127.0.0.1" : "0.0.0.0" , Port , UPnPPort , Hostname , SkinOnAct , false ) ;
10361063 }
10371064 else
10381065 {
1039- core . StartServer ( localhostOnly ? "127.0.0.1" : "0.0.0.0" , Port , Port , Hostname , SkinOnAct , UseSSL ) ;
1066+ core . StartServer ( localhostOnly ? "127.0.0.1" : "0.0.0.0" , Port , Port , Hostname , SkinOnAct , false ) ;
10401067 }
10411068 }
10421069 catch ( Exception e )
@@ -1048,7 +1075,7 @@ public void StartServer()
10481075 //OnLogLineReadUse.Enabled = false;
10491076 //MiniParseUse.Enabled = false;
10501077 //chatFilter.Enabled = false;
1051- SSLUse . Enabled = false ;
1078+ // SSLUse.Enabled = false;
10521079 skinOnAct . Enabled = false ;
10531080 UPNPUse . Enabled = false ;
10541081 randomURL . Enabled = false ;
@@ -1059,26 +1086,88 @@ public void StartServer()
10591086 buttonOff . Enabled = true ;
10601087
10611088
1062- string serviceType = "_overlay._tcp" ;
1089+ Task serviceTask = new Task ( ( ) =>
1090+ {
1091+ try
1092+ {
1093+ string serviceType = "_overlay._tcp" ;
1094+ lock ( serviceLock )
1095+ {
1096+ if ( serviceBrowser != null )
1097+ {
1098+ serviceBrowser . StopBrowse ( ) ;
1099+ serviceBrowser = null ;
1100+ }
1101+
1102+ {
1103+ serviceBrowser = new ServiceBrowser ( ) ;
1104+ serviceBrowser . ServiceAdded += onServiceAdded ;
1105+ serviceBrowser . ServiceRemoved += onServiceRemoved ;
1106+ serviceBrowser . ServiceChanged += onServiceChanged ;
1107+
1108+ Console . WriteLine ( "Browsing for type: {0}" , serviceType ) ;
1109+ serviceBrowser . StartBrowse ( serviceType ) ;
1110+ Console . ReadLine ( ) ;
1111+ }
1112+ }
1113+
1114+
1115+ String url = ( "http" ) + "://" + Hostname + ":" + Port + "/" ;
1116+ if ( ACTWebSocketCore . randomDir != null )
1117+ {
1118+ url += ACTWebSocketCore . randomDir + "/" ;
1119+ }
1120+ string address = string . Format ( "http://zcube.kr:8585/shorten?longUrl={0}" , Uri . EscapeDataString ( url ) ) ;
1121+
1122+ HttpWebRequest request = HttpWebRequest . CreateHttp ( address ) ;
1123+ WebResponse response = request . GetResponse ( ) ;
1124+ String res = "" ;
1125+ using ( StreamReader reader = new StreamReader ( response . GetResponseStream ( ) , Encoding . UTF8 ) )
1126+ {
1127+ res = reader . ReadToEnd ( ) ;
1128+ }
1129+
1130+ res = res ;
1131+ JObject obj = JObject . Parse ( res ) ;
1132+ JToken token ;
1133+ int status_code = 0 ;
1134+ String hash = "" ;
1135+ if ( obj . TryGetValue ( "status_code" , out token ) )
1136+ {
1137+ status_code = token . ToObject < int > ( ) ;
1138+ }
10631139
1064- ServiceBrowser serviceBrowser = new ServiceBrowser ( ) ;
1065- serviceBrowser . ServiceAdded += onServiceAdded ;
1066- serviceBrowser . ServiceRemoved += onServiceRemoved ;
1067- serviceBrowser . ServiceChanged += onServiceChanged ;
1140+ JObject data = ( JObject ) obj [ "data" ] ;
1141+ if ( data != null && data . TryGetValue ( "hash" , out token ) )
1142+ {
1143+ hash = token . ToObject < String > ( ) ;
1144+ }
1145+ hashCode . Text = hash ;
1146+ }
1147+ catch ( Exception e )
1148+ {
10681149
1069- Console . WriteLine ( "Browsing for type: {0}" , serviceType ) ;
1070- serviceBrowser . StartBrowse ( serviceType ) ;
1071- Console . ReadLine ( ) ;
1150+ }
1151+ } ) ;
1152+ serviceTask . Start ( ) ;
10721153 }
10731154
10741155 public void StopServer ( )
10751156 {
1157+ if ( serviceBrowser != null )
1158+ {
1159+ lock ( serviceLock )
1160+ {
1161+ serviceBrowser . StopBrowse ( ) ;
1162+ serviceBrowser = null ;
1163+ }
1164+ }
10761165 core . StopServer ( ) ;
10771166 //BeforeLogLineReadUse.Enabled = true;
10781167 //OnLogLineReadUse.Enabled = true;
10791168 //MiniParseUse.Enabled = true;
10801169 //chatFilter.Enabled = true;
1081- SSLUse . Enabled = true ;
1170+ // SSLUse.Enabled = true;
10821171 skinOnAct . Enabled = true ;
10831172 UPNPUse . Enabled = true ;
10841173 randomURL . Enabled = true ;
@@ -1229,7 +1318,7 @@ public string getURLPath(string skinPath = "", bool withRandomURL = true)
12291318 {
12301319 try
12311320 {
1232- string fullURL = ( UseSSL ? "https" : "http" ) + url + Uri . EscapeDataString ( skinPath ) ;
1321+ string fullURL = ( "http" ) + url + Uri . EscapeDataString ( skinPath ) ;
12331322 fullURL = fullURL . Replace ( "%5C" , "/" ) ;
12341323 fullURL = fullURL . Replace ( "%2F" , "/" ) ;
12351324 return fullURL ;
@@ -1262,7 +1351,7 @@ private void UpdateFormSettings()
12621351 BeforeLogLineRead = BeforeLogLineReadUse . Checked ;
12631352 OnLogLineRead = OnLogLineReadUse . Checked ;
12641353 MiniParse = MiniParseUse . Checked ;
1265- UseSSL = SSLUse . Checked ;
1354+ // UseSSL = SSLUse.Checked;
12661355 UseUPnP = UPNPUse . Checked ;
12671356 RandomURL = randomURL . Checked ;
12681357 SkinOnAct = skinOnAct . Checked ;
@@ -1313,7 +1402,7 @@ void onServiceAdded(object sender, ServiceAnnouncementEventArgs e)
13131402 HttpWebRequest webRequest = WebRequest . CreateHttp ( uri ) ;
13141403 webRequest . Headers . Add ( "Port" , Port . ToString ( ) ) ;
13151404 webRequest . Headers . Add ( "IP" , hostnames . Text . ToString ( ) ) ;
1316- webRequest . Headers . Add ( "SCHEME" , UseSSL ? "https" : "http" ) ;
1405+ webRequest . Headers . Add ( "SCHEME" , "http" ) ;
13171406 webRequest . BeginGetResponse ( null , webRequest ) ;
13181407 }
13191408
@@ -1472,7 +1561,6 @@ private void AddWebURL(string a)
14721561 } ) ;
14731562 Task UITask = task . ContinueWith ( ( t ) =>
14741563 {
1475- lock ( core . skinObject )
14761564 {
14771565 bool find = false ;
14781566 foreach ( ListViewItem i in WebSkinListView . Items )
@@ -1492,6 +1580,7 @@ private void AddWebURL(string a)
14921580 WebSkinListView . Items . Add ( lvi ) ;
14931581 if ( core != null )
14941582 {
1583+ lock ( core . skinObject )
14951584 {
14961585 JObject skinInfo = new JObject ( ) ;
14971586 skinInfo [ "Title" ] = title ;
@@ -1511,6 +1600,9 @@ private void AddWebURL(string a)
15111600 } , TaskScheduler . FromCurrentSynchronizationContext ( ) ) ;
15121601 }
15131602 List < Task > tasklist = new List < Task > ( ) ;
1603+ private ServiceBrowser serviceBrowser ;
1604+ private Object serviceLock = new Object ( ) ;
1605+
15141606 private void AddFileURL ( string a )
15151607 {
15161608 a = a . Replace ( "\\ " , "/" ) ;
@@ -1521,7 +1613,6 @@ private void AddFileURL(string a)
15211613 } ) ;
15221614 Task UITask = task . ContinueWith ( ( t ) =>
15231615 {
1524- lock ( core . skinObject )
15251616 {
15261617 bool find = false ;
15271618 foreach ( ListViewItem i in FileSkinListView . Items )
@@ -1641,7 +1732,7 @@ private void UPNPUse_CheckedChanged(object sender, EventArgs e)
16411732
16421733 private void UseSSL_CheckedChanged ( object sender , EventArgs e )
16431734 {
1644- UseSSL = SSLUse . Checked ;
1735+ // UseSSL = SSLUse.Checked;
16451736 }
16461737
16471738 private void skinOnAct_CheckedChanged ( object sender , EventArgs e )
@@ -1650,6 +1741,24 @@ private void skinOnAct_CheckedChanged(object sender, EventArgs e)
16501741 buttonRefresh_Click ( sender , e ) ;
16511742 }
16521743
1744+ private void buttonCopyCode_Click ( object sender , EventArgs e )
1745+ {
1746+ String id = hashCode . Text ;
1747+ Task task = Task . Factory . StartNew ( ( ) =>
1748+ {
1749+ string url = ( "http" ) + getURLPath ( "" ) ;
1750+ string address = string . Format ( "https://dev.zcube.kr/fcmhelper/v1/message?id={0}&message={1}" , Uri . EscapeDataString ( id ) , Uri . EscapeDataString ( url ) ) ;
1751+
1752+ HttpWebRequest request = HttpWebRequest . CreateHttp ( address ) ;
1753+ WebResponse response = request . GetResponse ( ) ;
1754+ String res = "" ;
1755+ using ( StreamReader reader = new StreamReader ( response . GetResponseStream ( ) , Encoding . UTF8 ) )
1756+ {
1757+ res = reader . ReadToEnd ( ) ;
1758+ }
1759+ } ) ;
1760+ }
1761+
16531762 void UpdateOverlayProc ( )
16541763 {
16551764 bool b = File . Exists ( overlayProcExe ) ;
@@ -1961,7 +2070,8 @@ private void ServerUrlChanged()
19612070
19622071 private void SSLUse_CheckedChanged ( object sender , EventArgs e )
19632072 {
1964-
2073+ //UseSSL = SSLUse.Checked;
19652074 }
2075+
19662076 }
19672077}
0 commit comments