cleanup composer/compositing/composition -> compositor
[AROS.git] / workbench / prefs / Editor / PrefsPort.c
bloba5ee323a124d8048a8d1e45d1a98012ba6c5f46d
1 /***************************************************************
2 **** PrefsPort.c: Communication port with JanoEditor ****
3 **** Free software under GNU license, started on 11/11/2000 ****
4 **** Written by T.Pierron ****
5 ***************************************************************/
7 #include <exec/types.h>
8 #include <exec/io.h>
9 #include <libraries/dos.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
14 #include <clib/alib_protos.h>
16 #include "Gui.h"
17 #include "Prefs.h"
18 #include "IPC_Prefs.h"
19 #include "JanoPrefs.h"
21 /** Port of Pref and Jano **/
22 static struct MsgPort *port, *reply;
23 static struct JPacket *cmd;
25 UBYTE *PortName = JANOPREFS_PORT;
27 /** Look if prefs isn't alredy running **/
28 char find_prefs( void )
30 ULONG sigwait;
31 if((reply = (struct MsgPort *) FindPort(PortName)))
33 PortName = NULL; /* Private port */
34 if(( sigwait = create_port() ))
36 /* Send to the running preference tool that someone tries to launch it again */
37 cmd->class = CMD_SHOW;
38 PutMsg(reply, (struct Message *)cmd);
39 /* cmd packet is associated with "port", thus reply will be done here */
40 Wait( sigwait );
41 /* Unqueue message (don't reply!) */
42 GetMsg( port );
44 /* Cleanup will be done later */
45 return 1;
46 } else return 0;
49 /** Setup public port of the preference editor **/
50 ULONG create_port( void )
52 /* Create a port and */
53 if(( port = (struct MsgPort *) CreatePort(PortName, 0L) ))
55 /* Create a message that can be sent to the editor */
56 if(( cmd = (struct JPacket *) CreateExtIO(port, (long) sizeof (*cmd)) ))
57 return (unsigned) (1L << port->mp_SigBit);
59 DeletePort(port);
61 return 0;
64 /** Search for a running session of editor **/
65 char find_jano(PREFS *prefs)
67 extern struct Screen *Scr;
68 if((reply = (struct MsgPort *) FindPort(JANO_PORT)))
70 /* Get a copy of the preferences that uses the editor */
71 cmd->class = CMD_PREF;
72 PutMsg(reply, (struct Message *)cmd);
73 Wait( 1 << port->mp_SigBit | SIGBREAKF_CTRL_C );
74 GetMsg( port );
75 /* Copy to our local buffer */
76 CopyMem(&cmd->prefs, prefs, sizeof(*prefs));
77 Scr = prefs->current;
78 return 1;
80 return 0;
83 /** Send a preference struct to Jano's public port **/
84 char send_jano(PREFS *prefs, ULONG class)
86 /* The port can be shutted down!! */
87 if(( reply = (struct MsgPort *) FindPort(JANO_PORT)))
89 cmd->class = class;
90 CopyMem(prefs, &cmd->prefs, sizeof(*prefs));
92 PutMsg(reply, (struct Message *)cmd);
93 Wait( 1 << port->mp_SigBit | SIGBREAKF_CTRL_C );
94 GetMsg( port );
95 return 1;
96 } else return 0;
99 /** Shutdown port **/
100 void close_port( void )
102 if( cmd ) DeleteExtIO((struct IORequest *)cmd);
103 if( port ) {
104 /* Be sure there are no message left */
105 struct Message *msg;
106 while((msg = GetMsg( port ))) ReplyMsg(msg);
107 DeletePort( port );
111 /** Handle messages posted to the public port **/
112 void handle_port( void )
114 struct JPacket *msg;
115 extern UBYTE ConfigFile;
116 while(( msg = (struct JPacket *) GetMsg(port) ))
118 switch( msg->class )
120 case CMD_SHOW: setup_guipref(); break;
121 case CMD_KILL:
122 /* Close preference tool only if it's associated to jano */
123 if( !ConfigFile ) close_prefwnd(0); break;
125 ReplyMsg((struct Message *)msg);