Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add GUI support for configuring the autologin profile in profiles.xml

  • Loading branch information...
commit eab6f80c1e73979124f631d4abcb7938ca489b5c 1 parent 17411f2
@leechguy leechguy authored
View
5 language/English/strings.po
@@ -11887,3 +11887,8 @@ msgstr ""
msgctxt "#37013"
msgid "(Directors Comments)"
msgstr ""
+
+#: xbmc/GUIInfoManager.cpp
+msgctxt "#37014"
+msgid "Most recent"
+msgstr ""
View
13 xbmc/GUIInfoManager.cpp
@@ -268,6 +268,7 @@ const infomap system_labels[] = {{ "hasnetwork", SYSTEM_ETHERNET_LINK_ACT
{ "profilename", SYSTEM_PROFILENAME },
{ "profilethumb", SYSTEM_PROFILETHUMB },
{ "profilecount", SYSTEM_PROFILECOUNT },
+ { "profileautologin", SYSTEM_PROFILEAUTOLOGIN },
{ "progressbar", SYSTEM_PROGRESS_BAR },
{ "batterylevel", SYSTEM_BATTERY_LEVEL },
{ "friendlyname", SYSTEM_FRIENDLY_NAME },
@@ -1751,6 +1752,18 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
case SYSTEM_PROFILECOUNT:
strLabel.Format("%i", CProfilesManager::Get().GetNumberOfProfiles());
break;
+ case SYSTEM_PROFILEAUTOLOGIN:
+ {
+ int profileId = CProfilesManager::Get().GetAutoLoginProfileId();
+ if (profileId == -1)
+ strLabel = g_localizeStrings.Get(37014); // Most recent
+ else
+ {
+ const CProfile *profile = CProfilesManager::Get().GetProfile(profileId);
+ strLabel = profile->getName();
@jmarshallnz Owner

Can you guarantee this pointer?

@leechguy
leechguy added a note

Good catch. When deleting the configured auto login profile this returns NULL and XBMC is no more.
I will add a check when deleting the profile and set m_autoLoginProfile to -1 when auto login profile is deleted.
I will also add a check in GetAutoLoginProfileId() and have it return -1 in case the m_autoLoginProfile is no longer valid.

@jmarshallnz Owner

It makes sense to just check the profile pointer returned to be sure, to be sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+ }
+ break;
case SYSTEM_LANGUAGE:
strLabel = g_guiSettings.GetString("locale.language");
break;
View
2  xbmc/GUIInfoManager.h
@@ -418,6 +418,8 @@ namespace INFO
#define FANART_COLOR3 1002
#define FANART_IMAGE 1003
+#define SYSTEM_PROFILEAUTOLOGIN 1004
+
#define PVR_CONDITIONS_START 1100
#define PVR_IS_RECORDING (PVR_CONDITIONS_START)
#define PVR_HAS_TIMER (PVR_CONDITIONS_START + 1)
View
14 xbmc/profiles/ProfilesManager.h
@@ -142,6 +142,20 @@ class CProfilesManager : public ISettingsHandler
int GetCurrentProfileId() const { return GetCurrentProfile().getId(); }
+ /*! \brief Retrieve the autologin profile id
+ Retrieves the autologin profile id. When set to -1, then the last
+ used profile will be loaded
+ \return the id to the autologin profile
+ */
+ int GetAutoLoginProfileId() const { return m_autoLoginProfile; }
+
+ /*! \brief Retrieve the autologin profile id
+ Retrieves the autologin profile id. When set to -1, then the last
+ used profile will be loaded
+ \return the id to the autologin profile
+ */
+ void SetAutoLoginProfileId(const int profileId) { m_autoLoginProfile = profileId; }
+
std::string GetUserDataFolder() const;
std::string GetProfileUserDataFolder() const;
std::string GetDatabaseFolder() const;
View
54 xbmc/profiles/windows/GUIWindowSettingsProfile.cpp
@@ -24,6 +24,7 @@
#include "profiles/ProfilesManager.h"
#include "Application.h"
#include "dialogs/GUIDialogContextMenu.h"
+#include "dialogs/GUIDialogSelect.h"
#include "profiles/dialogs/GUIDialogProfileSettings.h"
#include "network/Network.h"
#include "utils/URIUtils.h"
@@ -41,6 +42,7 @@ using namespace XFILE;
#define CONTROL_PROFILES 2
#define CONTROL_LASTLOADED_PROFILE 3
#define CONTROL_LOGINSCREEN 4
+#define CONTROL_AUTOLOGIN 5
CGUIWindowSettingsProfile::CGUIWindowSettingsProfile(void)
: CGUIWindow(WINDOW_SETTINGS_PROFILES, "SettingsProfile.xml")
@@ -168,6 +170,17 @@ bool CGUIWindowSettingsProfile::OnMessage(CGUIMessage& message)
CProfilesManager::Get().Save();
return true;
}
+ else if (iControl == CONTROL_AUTOLOGIN)
+ {
+ int currentId = CProfilesManager::Get().GetAutoLoginProfileId();
@jmarshallnz Owner

cosmetics - indent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ int profileId;
+ if (GetAutoLoginProfileChoice(profileId) && (currentId != profileId))
+ {
+ CProfilesManager::Get().SetAutoLoginProfileId(profileId);
+ CProfilesManager::Get().Save();
+ }
+ return true;
+ }
}
break;
}
@@ -219,3 +232,44 @@ void CGUIWindowSettingsProfile::OnInitWindow()
CGUIWindow::OnInitWindow();
}
+bool CGUIWindowSettingsProfile::GetAutoLoginProfileChoice(int &iProfile)
+{
+ CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
+ if (!dialog) return false;
+
+ // add items
+ // "Most recent" option comes first, so up indices by 1
+ int autoLoginProfileId = CProfilesManager::Get().GetAutoLoginProfileId() + 1;
+ CFileItemList items;
+ CFileItemPtr item(new CFileItem());
+ item->SetLabel(g_localizeStrings.Get(37014)); // Most recent
+ item->SetIconImage("unknown-user.png");
+ items.Add(item);
+
+ for (unsigned int i = 0; i < CProfilesManager::Get().GetNumberOfProfiles(); i++)
+ {
+ const CProfile *profile = CProfilesManager::Get().GetProfile(i);
+ CStdString locked = g_localizeStrings.Get(profile->getLockMode() > 0 ? 20166 : 20165);
+ CFileItemPtr item(new CFileItem(profile->getName()));
+ item->SetProperty("Addon.Summary", locked); // lock setting
@jmarshallnz Owner

hack, hack. Why is this information useful to the user?

@leechguy
leechguy added a note

Don't kill the messenger, I just refactored :)

I can imagine that this could be useful but at the moment it has no added value. I can imagine that locked profiles cannot be used as an auto login profile because you would need to enter the password when starting XBMC. However, at the moment this is not the case. When the profile is locked, it will still log you in automatically (this was also the case before this feature was merged when the most recent profile was password protected -> no password query next on startup).

I see two possible solutions:
1) Don't allow locked profiles to be used for auto login and as such also not offer them in the selection window. In this case the "Not locked" below the profile name would give a hint on what difference is between the listed and not listed profiles.
2) When a locked profile is selected as autologin profile, popup a window on startup with the option to either enter the password, or login as a different user.

May be for now it is just an indicator to make you think it through when you select a locked profile. You locked it for a reason, are you sure you want XBMC to always startup with this profile? Other than that I can't think of anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ CStdString thumb = profile->getThumb();
+ if (thumb.IsEmpty())
+ thumb = "unknown-user.png";
+ item->SetIconImage(thumb);
+ items.Add(item);
+ }
+
+ dialog->SetHeading(20093); // Profile name
+ dialog->Reset();
+ dialog->SetUseDetails(true);
+ dialog->EnableButton(true, 222); // Cancel
+ dialog->SetItems(&items);
+ dialog->SetSelected(autoLoginProfileId);
+ dialog->DoModal();
+
+ if (dialog->IsButtonPressed() || dialog->GetSelectedLabel() < 0)
+ return false; // user cancelled
+ iProfile = dialog->GetSelectedLabel() - 1;
+
+ return true;
+}
@jmarshallnz Owner

This seems a little bit clunky to me UI-wise. You have a list of profiles already anyway on the screen, yet you pop up a dialog with the exact same list (with the "recent" item appended) to choose one.

Perhaps it can be done without the repetition?

@leechguy
leechguy added a note

I think it is quite ok as it is. It gives a clear indication that you are configuring the auto login profile. Another option could be to repopulate the right part of the window, but I think it is then less obvious. At one time when I press the icon, it does 'this' and at another time it doest 'that'.
I could also make it such that simply clicking the Auto login button would cycle through 'Most recent' and the available profiles.
I've also thought about adding the option 'Use as Autologin' to the context menu, but then where are you going to put the 'Most recent' option? In the context menu, this seems a bit out of context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
1  xbmc/profiles/windows/GUIWindowSettingsProfile.h
@@ -41,4 +41,5 @@ class CGUIWindowSettingsProfile :
void LoadList();
void SetLastLoaded();
void ClearListItems();
+ bool GetAutoLoginProfileChoice(int &iProfile);
};
@jmarshallnz

Can you guarantee this pointer?

@jmarshallnz

hack, hack. Why is this information useful to the user?

@jmarshallnz

This seems a little bit clunky to me UI-wise. You have a list of profiles already anyway on the screen, yet you pop up a dialog with the exact same list (with the "recent" item appended) to choose one.

Perhaps it can be done without the repetition?

@leechguy

Good catch. When deleting the configured auto login profile this returns NULL and XBMC is no more.
I will add a check when deleting the profile and set m_autoLoginProfile to -1 when auto login profile is deleted.
I will also add a check in GetAutoLoginProfileId() and have it return -1 in case the m_autoLoginProfile is no longer valid.

@jmarshallnz

It makes sense to just check the profile pointer returned to be sure, to be sure.

@leechguy

Don't kill the messenger, I just refactored :)

I can imagine that this could be useful but at the moment it has no added value. I can imagine that locked profiles cannot be used as an auto login profile because you would need to enter the password when starting XBMC. However, at the moment this is not the case. When the profile is locked, it will still log you in automatically (this was also the case before this feature was merged when the most recent profile was password protected -> no password query next on startup).

I see two possible solutions:
1) Don't allow locked profiles to be used for auto login and as such also not offer them in the selection window. In this case the "Not locked" below the profile name would give a hint on what difference is between the listed and not listed profiles.
2) When a locked profile is selected as autologin profile, popup a window on startup with the option to either enter the password, or login as a different user.

May be for now it is just an indicator to make you think it through when you select a locked profile. You locked it for a reason, are you sure you want XBMC to always startup with this profile? Other than that I can't think of anything.

@leechguy

I think it is quite ok as it is. It gives a clear indication that you are configuring the auto login profile. Another option could be to repopulate the right part of the window, but I think it is then less obvious. At one time when I press the icon, it does 'this' and at another time it doest 'that'.
I could also make it such that simply clicking the Auto login button would cycle through 'Most recent' and the available profiles.
I've also thought about adding the option 'Use as Autologin' to the context menu, but then where are you going to put the 'Most recent' option? In the context menu, this seems a bit out of context.

Please sign in to comment.
Something went wrong with that request. Please try again.