SSthread is obsolete. The others were promoted to libscreensaver.so.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7040 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,50 +0,0 @@
|
|||||||
#include "ScreenSaverApp.h"
|
|
||||||
#include <ScreenSaver.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
extern SSstates nextAction;
|
|
||||||
extern int32 frame;
|
|
||||||
extern BView *view;
|
|
||||||
extern BScreenSaver *saver;
|
|
||||||
extern sem_id ssSem;
|
|
||||||
extern SSAwindow *win;
|
|
||||||
|
|
||||||
int32 screenSaverThread(void *none)
|
|
||||||
{
|
|
||||||
bool done=false;
|
|
||||||
while (!done)
|
|
||||||
switch (nextAction)
|
|
||||||
{
|
|
||||||
case DRAW:
|
|
||||||
saver->Draw(view,frame++);
|
|
||||||
break;
|
|
||||||
case DIRECTDRAW:
|
|
||||||
saver->DirectDraw(frame);
|
|
||||||
win->Lock();
|
|
||||||
saver->Draw(view,frame++);
|
|
||||||
win->Unlock();
|
|
||||||
break;
|
|
||||||
case STOP:
|
|
||||||
frame=0;
|
|
||||||
acquire_sem(ssSem);
|
|
||||||
break;
|
|
||||||
case EXIT:
|
|
||||||
done=true;
|
|
||||||
delete saver;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void callDirectConnected (direct_buffer_info *info)
|
|
||||||
{
|
|
||||||
saver->DirectConnected(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
void callSaverDelete(void)
|
|
||||||
{
|
|
||||||
delete saver;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
#include "ScreenSaverPrefs.h"
|
|
||||||
#include "StorageDefs.h"
|
|
||||||
#include "FindDirectory.h"
|
|
||||||
#include "File.h"
|
|
||||||
#include "Path.h"
|
|
||||||
#include "string.h" // Posix string functions
|
|
||||||
#include "String.h" // BString def
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
ScreenSaverPrefs::ScreenSaverPrefs(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the flattened settings BMessage from disk and parse it.
|
|
||||||
bool ScreenSaverPrefs::LoadSettings(void) {
|
|
||||||
bool ok;
|
|
||||||
char pathAndFile[B_PATH_NAME_LENGTH];
|
|
||||||
BPath path;
|
|
||||||
|
|
||||||
status_t found=find_directory(B_USER_SETTINGS_DIRECTORY,&path);
|
|
||||||
if (ok=(found==B_OK)) {
|
|
||||||
strncpy(pathAndFile,path.Path(),B_PATH_NAME_LENGTH-1);
|
|
||||||
strncat(pathAndFile,"/ScreenSaver_settings",B_PATH_NAME_LENGTH-1);
|
|
||||||
BFile ssSettings(pathAndFile,B_READ_ONLY);
|
|
||||||
if (B_OK==ssSettings.InitCheck())
|
|
||||||
{ // File exists. Unflatten the message and call the settings parser.
|
|
||||||
BMessage settings;
|
|
||||||
settings.Unflatten(&ssSettings);
|
|
||||||
ok=parseSettings (&settings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOnValue(BMessage *msg, char *name, int &result) {
|
|
||||||
int32 value;
|
|
||||||
if (B_OK == msg->FindInt32(name,&value)) // If screen saving is even enabled
|
|
||||||
result=value;
|
|
||||||
// printf ("Read parameter %s, setting it to:%d\n",name,result);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScreenSaverPrefs::parseSettings (BMessage *msg) {
|
|
||||||
int temp;
|
|
||||||
const char *strPtr,*passwordPointer;
|
|
||||||
char pathAndFile[B_PATH_NAME_LENGTH]; // Yes, this is very long...
|
|
||||||
BPath path;
|
|
||||||
|
|
||||||
passwordPointer=password;
|
|
||||||
setOnValue(msg,"timeflags",temp);
|
|
||||||
if (temp) // If screen saver is enabled, set blanktime.
|
|
||||||
setOnValue(msg,"timefade",blankTime);
|
|
||||||
else
|
|
||||||
blankTime=-1;
|
|
||||||
passwordTime=-1; // This is pessimistic - assume that password is off OR that a settings load will fail.
|
|
||||||
setOnValue(msg,"lockenable",temp);
|
|
||||||
if (temp && (B_OK == msg->FindString("lockmethod",&strPtr)))
|
|
||||||
{ // Get the password. Either from the settings file (that's secure) or the networking file (also secure).
|
|
||||||
if (strcmp(strPtr,"network")) // Not network, therefore from the settings file
|
|
||||||
if (B_OK == msg->FindString("lockpassword",&passwordPointer))
|
|
||||||
setOnValue(msg,"lockdelay",passwordTime);
|
|
||||||
else // Get from the network file
|
|
||||||
{
|
|
||||||
status_t found=find_directory(B_USER_SETTINGS_DIRECTORY,&path);
|
|
||||||
if (found==B_OK) {
|
|
||||||
FILE *networkFile=NULL;
|
|
||||||
char buffer[512],*start;
|
|
||||||
strncpy(pathAndFile,path.Path(),B_PATH_NAME_LENGTH-1);
|
|
||||||
strncat(pathAndFile,"/network",B_PATH_NAME_LENGTH-1);
|
|
||||||
// This ugly piece opens the networking file and reads the password, if it exists.
|
|
||||||
if ((networkFile=fopen(pathAndFile,"r")))
|
|
||||||
while (buffer==fgets(buffer,512,networkFile))
|
|
||||||
if ((start=strstr(buffer,"PASSWORD =")))
|
|
||||||
strncpy(password, start+10,strlen(start-11));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setOnValue(msg,"lockdelay",passwordTime);
|
|
||||||
}
|
|
||||||
if (B_OK != msg->FindString("modulename",&strPtr))
|
|
||||||
blankTime=-1; // If the module doesn't exist, never blank.
|
|
||||||
strcpy(moduleName,strPtr);
|
|
||||||
BString stateMsgName("modulesettings_");
|
|
||||||
stateMsgName+=moduleName;
|
|
||||||
msg->FindMessage(stateMsgName.String(),&stateMsg); // Doesn't matter if it fails - stateMsg would just continue to be empty
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#ifndef SCREEN_SAVER_PREFS_H
|
|
||||||
#define SCREEN_SAVER_PREFS_H
|
|
||||||
#include "Message.h"
|
|
||||||
|
|
||||||
class ScreenSaverPrefs
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ScreenSaverPrefs(void);
|
|
||||||
bool LoadSettings(void);
|
|
||||||
int BlankTime(void) {return blankTime;}
|
|
||||||
int CurrentTime(void) {return currentTime;}
|
|
||||||
int PasswordTime(void) {return passwordTime;}
|
|
||||||
char *ModuleName(void) {return moduleName;}
|
|
||||||
char *Password(void) {return password;}
|
|
||||||
BMessage *GetState(void) {return &stateMsg;}
|
|
||||||
void SetBlankTime(int );
|
|
||||||
void SetCurrentTime(int );
|
|
||||||
void SetPasswordTime(int );
|
|
||||||
void SetModuleName(char *);
|
|
||||||
void SetPassword(char *);
|
|
||||||
void SetState(BMessage *);
|
|
||||||
private:
|
|
||||||
bool parseSettings(BMessage *newSSMessage);
|
|
||||||
int blankTime;
|
|
||||||
int currentTime;
|
|
||||||
int passwordTime;
|
|
||||||
char moduleName[B_PATH_NAME_LENGTH];
|
|
||||||
char password[B_PATH_NAME_LENGTH];
|
|
||||||
BMessage stateMsg;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //SCREEN_SAVER_PREFS_H
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
#ifndef SCREEN_SAVER_THREAD_H
|
|
||||||
#include "ScreenSaverThread.h"
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "Screen.h"
|
|
||||||
#include "ScreenSaver.h"
|
|
||||||
#include "SSAwindow.h"
|
|
||||||
#include "ScreenSaverPrefs.h"
|
|
||||||
|
|
||||||
int32 threadFunc(void *data) {
|
|
||||||
ScreenSaverThread *ss=(ScreenSaverThread *)data;
|
|
||||||
ss->thread();
|
|
||||||
}
|
|
||||||
|
|
||||||
ScreenSaverThread::ScreenSaverThread(BScreenSaver *svr, SSAwindow *wnd, BView *vw, ScreenSaverPrefs *p) :
|
|
||||||
saver(svr),win(wnd),view(vw), pref(p), frame(0),snoozeCount(0) {
|
|
||||||
if (win) { // Running in full screen mode
|
|
||||||
saver->StartSaver(win->view,false);
|
|
||||||
win->SetFullScreen(true);
|
|
||||||
win->Show();
|
|
||||||
win->Lock();
|
|
||||||
win->view->SetViewColor(0,0,0);
|
|
||||||
win->view->SetLowColor(0,0,0);
|
|
||||||
win->Unlock();
|
|
||||||
win->Sync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenSaverThread::quit(void) {
|
|
||||||
saver->StopSaver();
|
|
||||||
if (win)
|
|
||||||
win->Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenSaverThread::thread() {
|
|
||||||
while (1) {
|
|
||||||
snooze(saver->TickSize());
|
|
||||||
if (snoozeCount) { // If we are sleeping, do nothing
|
|
||||||
snoozeCount--;
|
|
||||||
return;
|
|
||||||
} else if (saver->LoopOnCount() && (frame>=saver->LoopOnCount())) { // Time to nap
|
|
||||||
frame=0;
|
|
||||||
snoozeCount=saver->LoopOffCount();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (win) {
|
|
||||||
saver->DirectDraw(frame);
|
|
||||||
win->Lock();
|
|
||||||
}
|
|
||||||
saver->Draw(view,frame);
|
|
||||||
if (win) {
|
|
||||||
win->Unlock();
|
|
||||||
win->Sync();
|
|
||||||
}
|
|
||||||
frame++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#ifndef SCREEN_SAVER_THREAD_H
|
|
||||||
#define SCREEN_SAVER_THREAD_H
|
|
||||||
#include "SupportDefs.h"
|
|
||||||
|
|
||||||
class BScreenSaver;
|
|
||||||
class SSAwindow;
|
|
||||||
class BView;
|
|
||||||
class ScreenSaverPrefs;
|
|
||||||
|
|
||||||
int32 threadFunc(void *data);
|
|
||||||
|
|
||||||
class ScreenSaverThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ScreenSaverThread(BScreenSaver *svr, SSAwindow *wnd, BView *vw, ScreenSaverPrefs *p);
|
|
||||||
void thread(void);
|
|
||||||
void quit(void);
|
|
||||||
private:
|
|
||||||
BScreenSaver *saver;
|
|
||||||
SSAwindow *win;
|
|
||||||
BView *view;
|
|
||||||
ScreenSaverPrefs *pref;
|
|
||||||
|
|
||||||
long frame;
|
|
||||||
int snoozeCount;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //SCREEN_SAVER_THREAD_H
|
|
||||||
Reference in New Issue
Block a user