forked from dougma/lastfm-desktop
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unicorn::Application handles login. Unicorn::UserSettings is settings…
… per user for all apps in the suite. But we prolly will use it sparingly. git-svn-id: svn+ssh://svn.last.fm/svn/clientside/trunk/desktop@86489 ab8f4a45-97f9-0310-bbd1-854ce3dcee89
- Loading branch information
Showing
14 changed files
with
191 additions
and
95 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/*************************************************************************** | ||
* Copyright 2005-2008 Last.fm Ltd. * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
***************************************************************************/ | ||
|
||
#include "UnicornApplication.h" | ||
#include "LastMessageBox.h" | ||
#include "UnicornSettings.h" | ||
#include "widgets/LoginDialog.h" | ||
|
||
|
||
Unicorn::Application::Application( int argc, char** argv ) throw( StubbornUserException, UnsupportedPlatformException ) | ||
: QApplication( argc, argv ) | ||
{ | ||
#ifdef Q_WS_MAC | ||
if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_4) | ||
{ | ||
LastMessageBox::critical( | ||
QObject::tr( "Unsupported OS X Version" ), | ||
QObject::tr( "We are sorry, but Last.fm requires OS X Tiger or above." ) ); | ||
throw UnsupportedPlatformException(); | ||
} | ||
#endif | ||
|
||
Settings s; | ||
|
||
if (s.username().isEmpty() || s.logOutOnExit()) | ||
{ | ||
LoginDialog d; | ||
if (d.exec() == QDialog::Accepted) | ||
{ | ||
// we shouldn't store this really, if LogOutOnExit is enabled | ||
// but we delete the setting on exit, and it means other apps can | ||
// log in while the client is loaded, and prevents us having to | ||
// store these datas for the use case where LogOutOnExit is disabled | ||
// during the session | ||
Unicorn::QSettings s; | ||
s.setValue( "Username", d.username() ); | ||
s.setValue( "Password", d.password() ); | ||
} | ||
else | ||
{ | ||
throw StubbornUserException(); | ||
} | ||
} | ||
} | ||
|
||
|
||
Unicorn::Application::~Application() | ||
{ | ||
// we do this here, rather than when the setting is changed because if we | ||
// did it then the user would be unable to change their mind | ||
if (Unicorn::Settings().logOutOnExit()) | ||
{ | ||
Unicorn::QSettings s; | ||
s.remove( "Username" ); | ||
s.remove( "Password" ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*************************************************************************** | ||
* Copyright 2005-2008 Last.fm Ltd. * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
***************************************************************************/ | ||
|
||
#include <QApplication> | ||
|
||
|
||
namespace Unicorn | ||
{ | ||
class Application : public QApplication | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
// shows a message box advising user of error before throwing | ||
class UnsupportedPlatformException | ||
{}; | ||
|
||
class StubbornUserException | ||
{}; | ||
|
||
/** will put up the log in dialog if necessary, throwing if the user | ||
* cancels, ie. they refuse to log in */ | ||
Application( int, char** ) throw( StubbornUserException, UnsupportedPlatformException ); | ||
~Application(); | ||
}; | ||
} |
Oops, something went wrong.