Skip to content

Adds possibility to retreive userlist from Fritzbox at startup #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions PS.FritzBox.API.CMD/LanConfigSecurityHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public override async Task Handle()
this.PrintOutputAction($"LanConfigSecurityHandler{Environment.NewLine}########################");
this.PrintOutputAction("1 - GetAnonymousLogin");
this.PrintOutputAction("2 - GetCurrentUser");
this.PrintOutputAction("3 - GetInfo");
this.PrintOutputAction("4 - SetConfigPassword");
this.PrintOutputAction("3 - GetUserList");
this.PrintOutputAction("4 - GetInfo");
this.PrintOutputAction("5 - SetConfigPassword");
this.PrintOutputAction("r - Return");

input = this.GetInputFunc();
Expand All @@ -39,9 +40,12 @@ public override async Task Handle()
await this.GetCurrentUser();
break;
case "3":
await this.GetInfo();
await this.GetUserList();
break;
case "4":
await this.GetInfo();
break;
case "5":
await this.SetConfigPassword();
break;
case "r":
Expand Down Expand Up @@ -79,6 +83,14 @@ private async Task GetCurrentUser()
this.PrintObject(currentUser);
}

private async Task GetUserList()
{
this.ClearOutputAction();
this.PrintEntry();
var userList = await this._client.GetUserListAsync();
this.PrintObject(userList);
}

private async Task GetInfo()
{
this.ClearOutputAction();
Expand Down
1 change: 0 additions & 1 deletion PS.FritzBox.API.CMD/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ static async Task MainAsync(string[] args)

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

do
{
Console.Clear();
Expand Down
14 changes: 13 additions & 1 deletion PS.FritzBox.API/FritzBox/LANConfigSecurityClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,19 @@ public async Task<LANConfigSecurityUser> GetCurrentUserAsync()
return user;
}


/// <summary>
/// Method to get the user list
/// </summary>
/// <returns>the current userlist</returns>
public async Task<LANConfigSecurityUserList> GetUserListAsync()
{
XDocument document = await this.InvokeAsync("X_AVM-DE_GetUserList", null);
LANConfigSecurityUserList userList = new LANConfigSecurityUserList();

userList.UserList = document.Descendants("NewX_AVM-DE_UserList").First().Value;

return userList;
}

/// <summary>
/// Method to set the password for the current user
Expand Down
18 changes: 18 additions & 0 deletions PS.FritzBox.API/FritzBox/LANConfigSecurityUserList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace PS.FritzBox.API
{
/// <summary>
/// class representing a userlist
/// </summary>
public class LANConfigSecurityUserList
{
/// <summary>
/// gets or sets the userlist
/// </summary>
public string UserList { get; set; }

}
}