void User::set_setting(UserSettings setting, bool value) { UserSettings s = settings(); if (value) { s = UserSettings(s | setting); } else { s = UserSettings(s & (~setting)); } set_settings(s); }
void unicorn::Application::onUserGotInfo( WsReply* r ) { try { const char* key = UserSettings::subscriptionKey(); bool const value = r->lfm()["user"]["subscriber"].text().toInt() == 1; UserSettings().setValue( key, value ); } catch (WsDomElement& e) { qWarning() << e; } emit userGotInfo( r ); }
unicorn::Application::Application( int& argc, char** argv ) throw( StubbornUserException ) : QApplication( argc, argv ), m_logoutAtQuit( false ) { #ifdef Q_WS_MAC qt_mac_set_menubar_icons( false ); #endif CoreApplication::init(); #ifdef __APPLE__ AEEventHandlerUPP h = NewAEEventHandlerUPP( appleEventHandler ); AEInstallEventHandler( kCoreEventClass, kAEReopenApplication, h, 0, false ); #endif translate(); CoreSettings s; if (s.value( "Username" ).toString().isEmpty() || s.value( "SessionKey" ).toString().isEmpty() || Settings().logOutOnExit()) { LoginDialog d( s.value( "Username" ).toString() ); if (d.exec() == QDialog::Accepted) { // if LogOutOnExit is enabled, really, we shouldn't store these, // but it means other Unicorn apps can log in while the client is // loaded, and we delete the settings on exit if logOut is on s.setValue( "Username", d.username() ); s.setValue( "SessionKey", d.sessionKey() ); s.setValue( "Password", d.passwordHash() ); UserSettings().setValue( UserSettings::subscriptionKey(), d.isSubscriber() ); } else { throw StubbornUserException(); } } Ws::Username = s.value( "Username" ).toString(); Ws::SessionKey = s.value( "SessionKey" ).toString(); connect( AuthenticatedUser().getInfo(), SIGNAL(finished( WsReply* )), SLOT(onUserGotInfo( WsReply* )) ); #ifdef __APPLE__ setQuitOnLastWindowClosed( false ); #endif }
UserControl::UserControl() : QObject(), disqus(this, UserSettings().getAuthenticator()), disqusUser() {}