url.SetUserName(username);
// save the information for later
+ SaveAuthenticatedURL(url, saveDetails);
+ return true;
+}
+
+void CPasswordManager::SaveAuthenticatedURL(const CURL &url, bool saveToProfile)
+{
+ CSingleLock lock(m_critSection);
+
+ CStdString path = GetLookupPath(url);
CStdString authenticatedPath = url.Get();
if (!m_loaded)
Load();
- if (saveDetails)
+ if (saveToProfile)
{ // write to some random XML file...
m_permanentCache[path] = authenticatedPath;
Save();
// save for both this path and more generally the server as a whole.
m_temporaryCache[path] = authenticatedPath;
m_temporaryCache[GetServerLookup(path)] = authenticatedPath;
- return true;
}
void CPasswordManager::Clear()
\param url the URL to authenticate.
\return true if the user entered details, false if the user cancelled the dialog.
- \sa CURL
+ \sa CURL, SaveAuthenticatedURL
*/
bool PromptToAuthenticateURL(CURL &url);
/*!
+ \brief Save an authenticated URL.
+
+ This routine stores an authenticated URL in the temporary cache, and optionally
+ saves these details into the users profile.
+
+ \param url the URL to authenticate.
+ \param saveToProfile whether to save in the users profile, defaults to true.
+ \sa CURL, PromptToAuthenticateURL
+ */
+ void SaveAuthenticatedURL(const CURL &url, bool saveToProfile = true);
+
+ /*!
\brief Clear any previously cached passwords
*/
void Clear();
#include "settings/Settings.h"
#include "settings/GUISettings.h"
#include "guilib/LocalizeStrings.h"
+#include "PasswordManager.h"
using namespace std;
using namespace XFILE;
{
vector<CStdString> paths;
for (int i = 0; i < m_paths->Size(); i++)
+ {
if (!m_paths->Get(i)->GetPath().IsEmpty())
- paths.push_back(m_paths->Get(i)->GetPath());
+ { // strip off the user and password for smb paths (anything that the password manager can auth)
+ // and add the user/pass to the password manager - note, we haven't confirmed that it works
+ // at this point, but if it doesn't, the user will get prompted anyway in SMBDirectory.
+ CURL url(m_paths->Get(i)->GetPath());
+ if (url.GetProtocol() == "smb")
+ {
+ CPasswordManager::GetInstance().SaveAuthenticatedURL(url);
+ url.SetPassword("");
+ url.SetUserName("");
+ }
+ paths.push_back(url.Get());
+ }
+ }
return paths;
}