home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Spanish Scene 4
/
SpanishScene4.iso
/
Programas
/
DavidBarbion_Ind
/
backclock_V232c.lha
/
BackClock
/
sources
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-06-12
|
3KB
|
108 lines
/*****************************************************************************
*
* Nom : main.c
*
* version : $VER: main.c 1.2 (12.06.99)
*
* History of backclock
* V1.0: initial version
* V1.1: can be started from WB with Tooltypes
* added notifyintuition routines to close the window automatically
* v1.2: window can initialy sized thanks to tooltypes
* window goes to back every seconds
* first public release
* v1.3: close|open workbench now works
* changed clock style
* v2.0: Totally customizable via a GUI (no tooltypes anymore)
* v2.1: Transparent. Removed some unused code
* v2.32b: redraw window when (de)selected
* uses rtracker.library
* v2.32c: now stay in front of Workbench or Directory Opus
* last minute : now set task priority to -20
*
* future: customizable clock style
*
*****************************************************************************
*/
#include <intuition/intuition.h>
#include <dos/dos.h>
#include <exec/ports.h>
#include <exec/libraries.h>
#include <exec/memory.h>
#include <workbench/startup.h>
#include <proto/intuition.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include "utils.h"
/* bump revision
*/
char * nosense = "\0$VER: " TITLE " (12.06.99)" ;
void main() {
/* lance du CLI
*/
idWin * myprj ;
if (exists() == FALSE) {
SetTaskPri(FindTask(NULL), -20) ; // for those who don't use executive
Delay(50) ; // wait 1s on startup
if ((myprj = init(NULL)) != NULL) {
//writeDate(myprj) ;
processwin(myprj) ;
close(myprj) ;
}
}
}
void wbmain() {
/* lance du WB
*/
void main() ;
main() ;
}
int exists() {
/* backclock already launched
*/
int ret = FALSE ;
struct EasyStruct EZ ;
struct MsgPort * oldPort ;
struct MsgPort * replyPort ;
struct backMsg * msg ;
Forbid() ;
oldPort = FindPort("backclock") ;
Permit() ;
if (oldPort) {
/* le programme est deja lance
*/
EZ.es_StructSize = sizeof(struct EasyStruct) ;
EZ.es_Flags = NULL ;
EZ.es_Title = TITLE ;
EZ.es_TextFormat = "You are about to quit BackClock\nAre you sure ?" ;
EZ.es_GadgetFormat = "Quit|Cancel" ;
if (EasyRequestArgs(NULL, &EZ, NULL, NULL) == 1) {
/* utilisateur choisit quit
*/
if ((replyPort = CreateMsgPort()) != NULL) {
if ((msg = AllocVec(sizeof(struct backMsg), MEMF_PUBLIC)) != NULL) {
msg->execmsg.mn_Node.ln_Type = NT_MESSAGE ;
msg->execmsg.mn_Length = sizeof(struct backMsg) ;
msg->execmsg.mn_ReplyPort = replyPort ;
msg->Class = BC_Quit ; // stop !!!
PutMsg(oldPort, (struct Message*)msg) ;
WaitPort(replyPort) ;
DeleteMsgPort(replyPort) ;
FreeVec(msg) ;
ret=OK ;
}else {
ret=ERRORNOMEM ;
DeleteMsgPort(replyPort) ;
}
}else ret=ERRORNOMEM ;
}else ret = OK ;
}
return(ret) ;
}