Exemplo n.º 1
0
 public ClientHandler(FritzDevice device, Action <string> printOutput, Func <string> getInput, Action wait, Action clearOutput)
 {
     this.PrintOutputAction = printOutput;
     this.GetInputFunc      = getInput;
     this.WaitAction        = wait;
     this.ClearOutputAction = clearOutput;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Method to initialize the client handlers
        /// </summary>
        /// <param name="settings"></param>
        static void InitClientHandler(FritzDevice device)
        {
            _clientHandlers.Clear();
            Action          clearOutput = () => Console.Clear();
            Action          wait        = () => Console.ReadKey();
            Action <string> printOutput = (output) => Console.WriteLine(output);
            Func <string>   getInput    = () => Console.ReadLine();

            _clientHandlers.Add("1", new DeviceInfoClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("2", new DeviceConfigClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("3", new LanConfigSecurityHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("4", new LANEthernetInterfaceClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("5", new LANHostConfigManagementClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("6", new WANCommonInterfaceConfigClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("7", new WANIPConnectonClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("8", new WANPPPConnectionClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("9", new AppSetupClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("10", new Layer3ForwardingClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("11", new UserInterfaceClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("12", new WLANConfigurationClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("13", new WLANConfigurationClientHandler2(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("14", new WLANConfigurationClientHandler3(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("15", new WANDSLInterfaceConfigClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("16", new WANEthernetLinkConfigClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("17", new WANDSLLinkConfigClientHandler(device, printOutput, getInput, wait, clearOutput));
            _clientHandlers.Add("18", new SpeedtestClientHandler(device, printOutput, getInput, wait, clearOutput));
        }
Exemplo n.º 3
0
        static void Configure(FritzDevice device)
        {
            ConnectionSettings settings = GetConnectionSettings();

            device.GetServiceClient <DeviceInfoClient>(settings);
            InitClientHandler(settings);
        }
Exemplo n.º 4
0
        static void Configure(FritzDevice device)
        {
            ConnectionSettings settings = GetConnectionSettings();

            device.Credentials = new System.Net.NetworkCredential(settings.UserName, settings.Password);
            //device.GetServiceClient<DeviceInfoClient>(settings);
            InitClientHandler(device);
        }
Exemplo n.º 5
0
        private void txtBaseUrl_TextChanged(object sender, EventArgs e)
        {
            if (sender == this.txtUserName)
            {
                this.ConnectionSettings.UserName = this.txtUserName.Text;
            }
            else if (sender == this.txtPassword)
            {
                this.ConnectionSettings.Password = this.txtPassword.Text;
            }
            this.SelectedDevice = this.cboDevice.SelectedItem as FritzDevice;

            this.ValidateInputs();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Method to build the tree
        /// </summary>
        private void BuildTree(FritzDevice device)
        {
            // add category nodes
            this.BuildCategoryNode("System", ModuleCategory.System);
            this.BuildCategoryNode("Internet", ModuleCategory.Internet);
            this.BuildCategoryNode("Home Network", ModuleCategory.HomeNetwork);
            this.BuildCategoryNode("WLAN", ModuleCategory.WLAN);

            this._modules = this.GetModules();
            foreach (ModuleBase module in this._modules)
            {
                this.AppendModule(module, device);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Method to append a module to the tree
 /// </summary>
 /// <param name="module">the module</param>
 private void AppendModule(ModuleBase module, FritzDevice device)
 {
     foreach (TreeNode categoryNode in this.treeNavigation.Nodes)
     {
         if (categoryNode.Tag.Equals(module.Category))
         {
             TreeNode moduleNode = categoryNode.Nodes.Add(module.Name);
             moduleNode.Tag = module;
             this.imlTree.Images.Add(module.Icon);
             moduleNode.ImageIndex             =
                 moduleNode.SelectedImageIndex = this.imlTree.Images.Count - 1;
             module.ConnectionSettings         = this._connectionSettings;
             module.FritzDevice = device;
         }
     }
 }
Exemplo n.º 8
0
        protected async override void OnShown(EventArgs e)
        {
            Control                   ctrl    = this.ShowWaintingPanel("Searching for devices in the local network. Please wait...");
            DeviceLocator             locator = new DeviceLocator();
            IEnumerable <FritzDevice> devices = await locator.DiscoverAsync();

            this.Controls.Remove(ctrl);
            if (devices.Count() == 0)
            {
                MessageBox.Show("No Fritz!Box devices found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
            else
            {
                FritzDevice device = this.ShowConnectionSettings(devices);
                this.BuildTree(device);
            }

            base.OnShown(e);
        }
Exemplo n.º 9
0
 public UserInterfaceClientHandler(FritzDevice device, Action <string> printOutput, Func <string> getInput, Action wait, Action clearOutput) : base(device, printOutput, getInput, wait, clearOutput)
 {
     this._client = device.GetServiceClient <UserInterfaceClient>();
 }
Exemplo n.º 10
0
 public LANHostConfigManagementClientHandler(FritzDevice device, Action <string> printOutput, Func <string> getInput, Action wait, Action clearOutput) : base(device, printOutput, getInput, wait, clearOutput)
 {
     this._client = device.GetServiceClient <LANDevice.LANHostConfigManagementClient>();
 }
Exemplo n.º 11
0
 public DeviceInfoClientHandler(FritzDevice device, Action <string> printOutput, Func <string> getInput, Action wait, Action clearOutput) : base(device, printOutput, getInput, wait, clearOutput)
 {
     this._client = device.GetServiceClient <DeviceInfoClient>(); // new DeviceInfoClient(settings);
 }
Exemplo n.º 12
0
 public WANDSLLinkConfigClientHandler(FritzDevice device, Action <string> printOutput, Func <string> getInput, Action wait, Action clearOutput) : base(device, printOutput, getInput, wait, clearOutput)
 {
     this._client = device.GetServiceClient <WANDevice.WANConnectionDevice.WANDSLLinkConfigClient>();
 }
 public WANPPPConnectionClientHandler(FritzDevice device, Action <string> printOutput, Func <string> getInput, Action wait, Action clearOutput) : base(device, printOutput, getInput, wait, clearOutput)
 {
     _client = device.GetServiceClient <WANPPPConnectionClient>();
 }
 public WLANConfigurationClientHandler2(FritzDevice device, Action <string> printOutput, Func <string> getInput, Action wait, Action clearOutput) : base(device, printOutput, getInput, wait, clearOutput)
 {
     this._client = device.GetServiceClient <WLANConfigurationClient2>();
 }
Exemplo n.º 15
0
        static async Task MainAsync(string[] args)
        {
            Console.WriteLine("Searching for devices...");
            IEnumerable <FritzDevice> devices = await FritzDevice.LocateDevicesAsync();

            if (devices.Count() > 0)
            {
                Console.WriteLine($"Found {devices.Count()} devices.");
                string input       = string.Empty;
                int    deviceIndex = -1;
                do
                {
                    int counter = 0;
                    foreach (FritzDevice device in devices)
                    {
                        Console.WriteLine($"{counter} - {device.ModelName}");
                    }
                    counter++;

                    input = Console.ReadLine();
                } while (!Int32.TryParse(input, out deviceIndex) && (deviceIndex < 0 || deviceIndex >= devices.Count()));

                FritzDevice selected = devices.Skip(deviceIndex).First();
                Configure(selected);

                do
                {
                    Console.Clear();
                    Console.WriteLine(" 1 - DeviceInfo");
                    Console.WriteLine(" 2 - DeviceConfig");
                    Console.WriteLine(" 3 - LanConfigSecurity");
                    Console.WriteLine(" 4 - LANEthernetInterface");
                    Console.WriteLine(" 5 - LANHostConfigManagement");
                    Console.WriteLine(" 6 . WANCommonInterfaceConfig");
                    Console.WriteLine(" 7 - WANIPPConnection");
                    Console.WriteLine(" 8 - WANPPPConnection");
                    Console.WriteLine(" 9 - AppSetup");
                    Console.WriteLine("10 - Layer3Forwarding");
                    Console.WriteLine("11 - UserInterface");
                    Console.WriteLine("12 - WLANConfiguration");
                    Console.WriteLine("13 - WLANConfiguration2");
                    Console.WriteLine("14 - WLANConfiguration3");
                    Console.WriteLine("15 - WANDSLInterfaceConfig");
                    Console.WriteLine("16 - WANEthernetLinkConfig");
                    Console.WriteLine("17 - WANDSLLinkConfig");
                    Console.WriteLine("18 - Speedtest");

                    Console.WriteLine("r - Reinitialize");
                    Console.WriteLine("q - Exit");

                    input = Console.ReadLine();
                    if (_clientHandlers.ContainsKey(input))
                    {
                        await _clientHandlers[input].Handle();
                    }
                    else if (input.ToLower() == "r")
                    {
                        Configure(selected);
                    }
                    else if (input.ToLower() != "q")
                    {
                        Console.WriteLine("invalid choice");
                    }
                } while (input.ToLower() != "q");
            }
            else
            {
                Console.WriteLine("No devices found");
                Console.ReadLine();
            }
        }
 public LanConfigSecurityHandler(FritzDevice device, Action <string> printOutput, Func <string> getInput, Action wait, Action clearOutput) : base(device, printOutput, getInput, wait, clearOutput)
 {
     this._client = device.GetServiceClient <LANConfigSecurityClient>();
 }
Exemplo n.º 17
0
 public Layer3ForwardingClientHandler(FritzDevice device, Action <string> printOutput, Func <string> getInput, Action wait, Action clearOutput) : base(device, printOutput, getInput, wait, clearOutput)
 {
     _client = device.GetServiceClient <Layer3ForwardingClient>();
 }