Пример #1
0
        public DLReply Ask()
        {
            Filename = System.Net.WebUtility.UrlDecode(Filename);
            TryPatchBaiduFileName();
            ContentType = ContentType.Split(';')[0];
            AskDL askDL = new AskDL(this);

            askDL.ShowDialog();
            if (askDL.DialogResult == DialogResult.OK)
            {
                switch (askDL.RetAgent)
                {
                case DLAgent.Default:
                    break;

                case DLAgent.Thunder:
                case DLAgent.EagleGet:
                case DLAgent.Idm:
                case DLAgent.Customized:
                {
                    ChainStart(askDL.RetAgent);
                }
                break;

                default:
                    break;
                }
            }
            DLReply reply = new DLReply(askDL.RetAgent, askDL.SaveDownload, askDL.SavedHost);

            return(reply);
        }
Пример #2
0
		private static void SendMsg(DLReply r)
		{
			BinaryWriter stdos = new BinaryWriter(Console.OpenStandardOutput(), Encoding.UTF8);
			string msg = JsonConvert.SerializeObject(r);
			stdos.Write(msg.Length);
			stdos.Write(msg.ToCharArray());
			stdos.Flush();
		}
Пример #3
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                switch (args[0].ToLower())
                {
                case "breaked":
                {
                    NamedPipeClientStream aPipeClient = new NamedPipeClientStream(args[1]);
                    BinaryReader          br          = new BinaryReader(aPipeClient);
                    aPipeClient.Connect(5000);
                    string sTask = br.ReadString();
                    aPipeClient.Close();
                    DLTask dt = JsonConvert.DeserializeObject <DLTask>(sTask);
                    dt.Perform();
                    break;
                }

                default:
                {
                    Web_ext_Message msg   = GetMsg();
                    DLRequest       req   = msg.Dispatch();
                    DLReply         reply = req.Process();
                    SendMsg(reply);
                    break;
                }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                DBG       dbg = new DBG();
                DLRequest r   = new DLRequest();
                r.RequestType   = "Download";
                r.ContentLength = "1G";
                dbg.ShowDialog();
                CheckInstallation();
            }
        }
Пример #4
0
		static void Main(string[] args)
		{
			Application.EnableVisualStyles();
			if (args.Length > 0)
			{
				switch(args[0].ToLower())
				{
					case "breaked":
						{
							NamedPipeClientStream aPipeClient = new NamedPipeClientStream(args[1]);
							BinaryReader br = new BinaryReader(aPipeClient);
							aPipeClient.Connect(5000);
							string sTask = br.ReadString();
							aPipeClient.Close();
							DLTask dt = JsonConvert.DeserializeObject<DLTask>(sTask);
							dt.Perform();
							break;
						}
					case "fix":
						{
							string thunderexe = args[1];
							string thunderagentdll = args[2];
							string thunderagent64bit = thunderagentdll.ToLower().Replace("thunderagent.dll", "thunderagent64.dll");
							Stack<string> tpaths = new Stack<string>(thunderexe.Split('\\'));
							tpaths.Pop();
							if (tpaths.Peek().ToLower() == "program")
								tpaths.Pop();
							string thunderroot = string.Join("\\", tpaths.Reverse())+"\\";
							string version = FileVersionInfo.GetVersionInfo(thunderexe).FileVersion.Replace(',','.');
							if (Environment.Is64BitOperatingSystem && Environment.Is64BitProcess)
							{
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Thunder Network\ThunderOem\thunder_backwnd", "dir", thunderroot, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Thunder Network\ThunderOem\thunder_backwnd", "Path", thunderexe, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Thunder Network\ThunderOem\thunder_backwnd", "instdir", thunderroot, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Thunder Network\ThunderOem\thunder_backwnd", "Version", version, RegistryValueKind.String);
							}
							else
							{
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Thunder Network\ThunderOem\thunder_backwnd", "dir", thunderroot, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Thunder Network\ThunderOem\thunder_backwnd", "Path", thunderexe, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Thunder Network\ThunderOem\thunder_backwnd", "instdir", thunderroot, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Thunder Network\ThunderOem\thunder_backwnd", "Version", version, RegistryValueKind.String);
							}
							Process.Start("regsvr32", "/s \"" + thunderagentdll + "\"");
							if (Environment.Is64BitOperatingSystem && File.Exists(thunderagent64bit))
							{
								Process.Start("regsvr32", "/s \"" + thunderagent64bit + "\"");
							}
							else
							{
								MessageBox.Show((IWin32Window)null,Strings.This_copy_of_Thunder_supports_32_bit_only);
							}
							break;
						}
					default:
						{
							Web_ext_Message msg = GetMsg();
							DLRequest req = msg.Dispatch();
							DLReply reply = req.Process();
							SendMsg(reply);
							break;
						}
				}
			}
			else
			{
				DMThunder dM = new DMThunder
				{
					Url = "http://baidu.com/index.html",
					PostData = new PostInfo()
				};
				dM.Fire();
				WelcomeDialog dialog = new WelcomeDialog();
				dialog.ShowDialog();
			}
		}