Permalink
Browse files

Added reauth for when there is an auth error when setting the location

of the player. closes #18.
  • Loading branch information...
klnusbaum committed Aug 25, 2012
1 parent f7e4a4a commit 88f310aa93c3d5cfd81baf48ba0e0a92f1c4e0e0
Showing with 46 additions and 91 deletions.
  1. +21 −21 src/DataStore.cpp
  2. +8 −38 src/DataStore.hpp
  3. +11 −0 src/MetaWindow.cpp
  4. +5 −0 src/MetaWindow.hpp
  5. +0 −5 src/PlayerDashboard.cpp
  6. +1 −15 src/SetLocationDialog.cpp
  7. +0 −12 src/SetLocationDialog.hpp
View
@@ -87,13 +87,6 @@ DataStore::DataStore(
this,
SLOT(onPlayerPasswordSetError(const QString&, int, const QList<QNetworkReply::RawHeaderPair>&)));
-
- connect(
- serverConnection,
- SIGNAL(playerLocationSet(const QString&, const QString&, const QString&, const QString&)),
- this,
- SLOT(onPlayerLocationSet(const QString&, const QString&, const QString&, const QString&)));
-
connect(
serverConnection,
SIGNAL(playerLocationSetError(const QString&, int, const QList<QNetworkReply::RawHeaderPair>&)),
@@ -320,32 +313,31 @@ void DataStore::setPlayerLocation(
const QString& state,
const QString& zipcode
)
-{
- serverConnection->setPlayerLocation(streetAddress, city, state, zipcode);
-}
-
-void DataStore::onPlayerLocationSet(
- const QString& streetAddress,
- const QString& city,
- const QString& state,
- const QString& zipcode
-)
{
QSettings settings(QSettings::UserScope, getSettingsOrg(), getSettingsApp());
settings.setValue(getAddressSettingName(), streetAddress);
settings.setValue(getCitySettingName(), city);
settings.setValue(getStateSettingName(), state);
settings.setValue(getZipCodeSettingName(), zipcode);
+ serverConnection->setPlayerLocation(streetAddress, city, state, zipcode);
emit playerLocationSet();
}
+
void DataStore::onPlayerLocationSetError(
const QString& errMessage,
- int /*errorCode*/,
- const QList<QNetworkReply::RawHeaderPair>& /*headers*/)
+ int errorCode,
+ const QList<QNetworkReply::RawHeaderPair>& headers)
{
- //TODO handle reauth error
- emit playerLocationSetError(errMessage);
+ if(isTicketAuthError(errorCode, headers)){
+ Logger::instance()->log("Got the ticket-hash challenge");
+ reauthActions.insert(SET_PLAYER_LOCATION);
+ initReauth();
+ }
+ else{
+ //TODO handle location not found error
+ emit playerLocationSetError(errMessage);
+ }
}
void DataStore::pausePlayer(){
@@ -1020,6 +1012,7 @@ void DataStore::onReauth(const QByteArray& ticketHash, const user_id_t& userId){
}
void DataStore::doReauthAction(const ReauthAction& action){
+ QSettings settings(QSettings::UserScope, getSettingsOrg(), getSettingsApp());
switch(action){
case SYNC_LIB:
syncLibrary();
@@ -1044,6 +1037,13 @@ void DataStore::doReauthAction(const ReauthAction& action){
case SET_PLAYER_INACTIVE:
serverConnection->setPlayerState(getInactiveState());
break;
+ case SET_PLAYER_LOCATION:
+ serverConnection->setPlayerLocation(
+ settings.value(getAddressSettingName()).toString(),
+ settings.value(getCitySettingName()).toString(),
+ settings.value(getStateSettingName()).toString(),
+ settings.value(getZipCodeSettingName()).toString());
+ break;
}
}
View
@@ -53,7 +53,8 @@ Q_OBJECT
MOD_PLAYLIST,
SET_CURRENT_VOLUME,
SET_PLAYER_STATE,
- SET_PLAYER_INACTIVE
+ SET_PLAYER_INACTIVE,
+ SET_PLAYER_LOCATION
};
/**
@@ -1014,7 +1015,6 @@ public slots:
*/
void playerSetInactiveError(const QString& errMessage);
-
/**
* \brief Emitted when there was an error setting the player to "playing".
*
@@ -1030,7 +1030,7 @@ public slots:
void pausePlayerError(const QString& errMessage);
/**
- * \brief Emitted when the player's password has been removed.
+ * \brief Emitted when the player's password has been removed by a component of this client.
*/
void playerPasswordRemoved();
@@ -1042,7 +1042,7 @@ public slots:
void playerPasswordRemoveError(const QString& errMessage);
/**
- * \brief Emitted when the player's password is set.
+ * \brief Emitted when the player's password is set by a compenent of this client.
*/
void playerPasswordSet();
@@ -1054,7 +1054,7 @@ public slots:
void playerPasswordSetError(const QString& errMessage);
/**
- * \brief Emitted when the players location has been set.
+ * \brief Emitted when the player's location is set by a component of this client.
*/
void playerLocationSet();
@@ -1065,20 +1065,6 @@ public slots:
*/
void playerLocationSetError(const QString& errMessage);
- /**
- * \brief Emitted when the players name is succesfully changed.
- *
- * \param newName The new name the player was set to.
- */
- void playerNameChanged(const QString& newName);
-
- /**
- * \brief Emitted when changing the players name failes.
- *
- * \param errMessage An error message describing the failure.
- */
- void playerNameChangeError(const QString& errMessage);
-
/**
* \brief Emitted when the library table is modified.
*/
@@ -1109,7 +1095,7 @@ public slots:
void playerCreationFailed(const QString errMessage);
/**
- * \brief Emitted when the active playlist is modified.
+ * \brief Emitted when the active playlist is modified by the server.
*/
void activePlaylistModified();
@@ -1121,14 +1107,14 @@ public slots:
void manualSongChange(DataStore::song_info_t newSong);
/**
- * \brief Emitted when the players state is changed.
+ * \brief Emitted when the players state is changed by the server.
*
* \param newState The new state of the player.
*/
void playerStateChanged(const QString& newState);
/**
- * \brief Emitted when the volume of the player is changed.
+ * \brief Emitted when the volume of the player is changed by the server.
*
* @param newVolume The new volume of the player.
*/
@@ -1474,22 +1460,6 @@ private slots:
int errorCode,
const QList<QNetworkReply::RawHeaderPair>& headers);
-
- /**
- * \brief Preforms appropriate tasks when a players location was succesfully set.
- *
- * \brief streetAddress The street address of location that was set for the player.
- * \brief city The city of location that was set for the player.
- * \brief state The state of location that was set for the player.
- * \brief zipcode The zipcode of location that was set for the player.
- */
- void onPlayerLocationSet(
- const QString& streetAddress,
- const QString& city,
- const QString& state,
- const QString& zipcode
- );
-
/**
* \brief Preforms appropriate tasks when there was an error setting the player's location.
*
View
@@ -124,6 +124,11 @@ MetaWindow::MetaWindow(
SIGNAL(hardAuthFailure()),
this,
SLOT(onHardAuthFailure()));
+ connect(
+ dataStore,
+ SIGNAL(playerLocationSetError(const QString&)),
+ this,
+ SLOT(onPlayerLocationSetError(const QString&)));
}
void MetaWindow::closeEvent(QCloseEvent *event){
@@ -503,4 +508,10 @@ void MetaWindow::onHardAuthFailure(){
close();
}
+void MetaWindow::onPlayerLocationSetError(const QString& errMessage){
+ QMessageBox::critical(this, tr("Error Setting Location"), errMessage);
+ setPlayerLocation();
+}
+
+
} //end namespace
View
@@ -97,6 +97,11 @@ private slots:
/** \brief Inform the user their current credentials no longer work. */
void onHardAuthFailure();
+ /**
+ * \brief Performs appropriate actions when there is an error setting the location of the player.
+ */
+ void onPlayerLocationSetError(const QString& errMessage);
+
/** \brief Shows the logger view. */
void displayLogView();
View
@@ -33,11 +33,6 @@ PlayerDashboard::PlayerDashboard(DataStore *dataStore, QWidget *parent):
SIGNAL(playerCreated()),
this,
SLOT(setPlayerInfo()));
- connect(
- dataStore,
- SIGNAL(playerNameChanged(const QString&)),
- this,
- SLOT(setPlayerInfo()));
connect(
dataStore,
SIGNAL(playerLocationSet()),
View
@@ -39,24 +39,9 @@ SetLocationDialog::SetLocationDialog(DataStore *dataStore, QWidget *parent, Qt::
setWindowTitle(tr("Set Player Location"));
setModal(true);
setupUi();
- connect(dataStore, SIGNAL(playerLocationSet()), this, SLOT(closeDialog()));
- connect(
- dataStore,
- SIGNAL(playerLocationSetError(const QString&)),
- this,
- SLOT(onChangeLocationError(const QString&)));
}
-void SetLocationDialog::onChangeLocationError(const QString& errMessage){
- this->showMainWidget();
- QMessageBox::critical(
- this,
- tr("Couldn't Change Location"),
- errMessage
- );
-}
-
void SetLocationDialog::accept(){
QString badInputs = addressWidget->getBadInputs();
if(badInputs == ""){
@@ -67,6 +52,7 @@ void SetLocationDialog::accept(){
addressWidget->getState(),
addressWidget->getZipcode()
);
+ closeDialog();
}
else{
QMessageBox::critical(
View
@@ -78,18 +78,6 @@ public slots:
//@}
-private slots:
- /** @name Private Slots */
- //@{
-
- /**
- * \brief Handles location change errors
- *
- * \param errMessage A message describing the error.
- */
- void onChangeLocationError(const QString& errMessage);
-
- //@}
};

0 comments on commit 88f310a

Please sign in to comment.