improved password handling
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13965 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3406dc829e
commit
0b0923357e
@ -21,16 +21,17 @@ PasswordWindow::Setup()
|
||||
BRect bounds(fBgd->Bounds());
|
||||
bounds.InsetBy(5,5);
|
||||
|
||||
fCustomBox = new BBox(bounds,"custBeBox",B_FOLLOW_NONE);
|
||||
fCustomBox = new BBox(bounds, "custBeBox", B_FOLLOW_NONE);
|
||||
fCustomBox->SetLabel("Unlock screen saver");
|
||||
fBgd->AddChild(fCustomBox);
|
||||
|
||||
fPassword = new BTextControl(BRect(10,28,255,47),"pwdCntrl","Enter fPassword:",NULL,B_FOLLOW_NONE);
|
||||
fPassword = new BTextControl(BRect(10,28,255,47),"pwdCntrl","Enter password:", NULL, B_FOLLOW_NONE);
|
||||
fPassword->TextView()->HideTyping(true);
|
||||
fPassword->SetDivider(100);
|
||||
fCustomBox->AddChild(fPassword);
|
||||
|
||||
fUnlock = new BButton(BRect(160,70,255,85), "fUnlock", "Unlock", new BMessage(UNLOCK_MESSAGE), B_FOLLOW_NONE);
|
||||
fUnlock->SetTarget(NULL,be_app);
|
||||
fUnlock->SetTarget(NULL, be_app);
|
||||
fCustomBox->AddChild(fUnlock);
|
||||
fUnlock->MakeDefault(true);
|
||||
}
|
||||
|
@ -21,12 +21,11 @@ SSAwindow::SSAwindow(BRect frame)
|
||||
SSAwindow::~SSAwindow()
|
||||
{
|
||||
Hide();
|
||||
// Sync();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SSAwindow::QuitRequested(void)
|
||||
SSAwindow::QuitRequested()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <Debug.h>
|
||||
#include <stdio.h>
|
||||
#include <Screen.h>
|
||||
#include <image.h>
|
||||
@ -36,7 +37,7 @@ ScreenSaverApp::ScreenSaverApp()
|
||||
|
||||
|
||||
void
|
||||
ScreenSaverApp::ReadyToRun(void)
|
||||
ScreenSaverApp::ReadyToRun()
|
||||
{
|
||||
if (!fPref.LoadSettings())
|
||||
exit(1);
|
||||
@ -44,7 +45,7 @@ ScreenSaverApp::ReadyToRun(void)
|
||||
BScreen theScreen(B_MAIN_SCREEN_ID);
|
||||
fWin = new SSAwindow(theScreen.Frame());
|
||||
fPww = new PasswordWindow();
|
||||
fThrd = new ScreenSaverThread(fWin,fWin->fView,&fPref);
|
||||
fThrd = new ScreenSaverThread(fWin ,fWin->fView, &fPref);
|
||||
|
||||
fSaver = fThrd->LoadAddOn();
|
||||
if (!fSaver)
|
||||
@ -52,7 +53,7 @@ ScreenSaverApp::ReadyToRun(void)
|
||||
fWin->SetSaver(fSaver);
|
||||
fWin->SetFullScreen(true);
|
||||
fWin->Show();
|
||||
fThreadID = spawn_thread(ScreenSaverThread::ThreadFunc,"ScreenSaverRenderer",0,fThrd);
|
||||
fThreadID = spawn_thread(ScreenSaverThread::ThreadFunc,"ScreenSaverRenderer", B_LOW_PRIORITY,fThrd);
|
||||
resume_thread(fThreadID);
|
||||
HideCursor();
|
||||
}
|
||||
@ -60,7 +61,7 @@ ScreenSaverApp::ReadyToRun(void)
|
||||
|
||||
|
||||
void
|
||||
ScreenSaverApp::ShowPW(void)
|
||||
ScreenSaverApp::ShowPW()
|
||||
{
|
||||
fWin->Lock();
|
||||
suspend_thread(fThreadID);
|
||||
@ -79,7 +80,10 @@ ScreenSaverApp::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch(message->what) {
|
||||
case UNLOCK_MESSAGE:
|
||||
if (strcmp(fPww->GetPassword(),fPref.Password())) {
|
||||
{
|
||||
char salt[3] = "";
|
||||
strncpy(salt, fPref.Password(), 2);
|
||||
if (strcmp(crypt(fPww->GetPassword(), salt),fPref.Password())) {
|
||||
beep();
|
||||
fPww->Hide();
|
||||
fWin->SetFullScreen(true);
|
||||
@ -87,16 +91,11 @@ ScreenSaverApp::MessageReceived(BMessage *message)
|
||||
resume_thread(fThreadID);
|
||||
}
|
||||
else {
|
||||
printf ("Quitting!\n");
|
||||
PRINT(("Quitting!\n"));
|
||||
Shutdown();
|
||||
}
|
||||
break;
|
||||
case 'MOO1':
|
||||
if (real_time_clock()-fBlankTime>fPref.PasswordTime())
|
||||
ShowPW();
|
||||
else
|
||||
Shutdown();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
break;
|
||||
@ -104,6 +103,18 @@ ScreenSaverApp::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ScreenSaverApp::QuitRequested()
|
||||
{
|
||||
if (system_time()-fBlankTime>fPref.PasswordTime()) {
|
||||
ShowPW();
|
||||
return false;
|
||||
} else
|
||||
Shutdown();
|
||||
return BApplication::QuitRequested();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScreenSaverApp::Shutdown(void)
|
||||
{
|
||||
|
@ -18,8 +18,7 @@ public:
|
||||
ScreenSaverApp();
|
||||
bool LoadAddOn();
|
||||
void ReadyToRun();
|
||||
// bool QuitRequested();
|
||||
// void Quit();
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
void ShowPW();
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user