Added VA/AV Protocol support (not used yet).

This commit is contained in:
Ole Loots 2014-01-02 17:46:21 +01:00
parent ad3f3590e4
commit cd70ecd405
4 changed files with 305 additions and 0 deletions

View File

@ -105,6 +105,14 @@ short gemtk_dd_sexts(short fd, char *exts);
short gemtk_dd_rtry(short fd, char *name, char *file, char *whichext, long *size);
short gemtk_dd_reply(short fd, char ack);
/* -------------------------------------------------------------------------- */
/* AV/VA Protocol Module */
/* -------------------------------------------------------------------------- */
int gemtk_av_init(const char *appname);
void gemtk_av_exit(void);
bool gemtk_av_send (short message, const char * data1, const char * data2);
bool gemtk_av_dispatch (short msg[8]);
/* -------------------------------------------------------------------------- */
/* Message Box module */
/* -------------------------------------------------------------------------- */

View File

@ -25,6 +25,7 @@
#include <cflib.h>
#include "gemtk.h"
#include "vaproto.h"
//#define DEBUG_PRINT(x) printf x
#define DEBUG_PRINT(x)
@ -617,6 +618,11 @@ short gemtk_wm_dispatch_event(EVMULT_IN *ev_in, EVMULT_OUT *ev_out, short msg[8]
}
break;
case VA_PROTOSTATUS:
case VA_VIEWED:
case AV_STARTED:
gemtk_av_dispatch(msg);
break;
}
} else {

170
atari/gemtk/vaproto.c Normal file
View File

@ -0,0 +1,170 @@
#include <limits.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <gem.h>
#include "vaproto.h"
#include "gemtk.h"
#ifndef NDEBUG
# define DEBUG_PRINT(x) printf x
#else
# define DEBUG_PRINT(x)
#endif
/* Global memory, at least 1024 bytes large: */
static char *va_helpbuf;
/* Desktop's AES ID: */
static short av_shell_id = -1;
/* What AV commands can desktop do? */
static short av_shell_status = 0;
/* The application name used for AV/VA messages: */
static const char * av_clientname = "gemtk_av_app";
static short get_avserver(void)
{
short ret = -100;
const char * av_env = getenv("AVSERVER");
if (av_env) {
char av_envname[9];
strncpy(av_envname,av_env, 8);
av_envname[8] = '\0';
while (strlen (av_envname) < 8) {
strcat(av_envname, " ");
}
ret = appl_find (av_envname);
}
return ret;
}
/**
* initialitze the AV client API
* \param appname Name of the application passed to menu_register()
* \return returns 1 on success, otherwise an negative error code.
*
*/
int gemtk_av_init(const char *appname)
{
short mode = 0x0003 /* prefer TT ram */
| 0x0020; /* global accesible */
if(av_shell_id != -1) {
/* Already initialized */
return(1);
}
va_helpbuf = (char*)Mxalloc(1024, mode);
if(va_helpbuf == NULL){
gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, "Could not allocate AV memory!");
return(-1);
}
if(appname != NULL){
av_clientname = appname;
}
av_shell_id = get_avserver();
DEBUG_PRINT(("AV Server ID: %d", av_shell_id));
gemtk_av_send(AV_PROTOKOLL, NULL, NULL);
va_helpbuf[0] = '\0';
}
void gemtk_av_exit(void)
{
if(av_shell_id == -1) {
/* Nothing to do */
return;
}
if (av_shell_status & AA_EXIT) {
/* AV server knows AV_EXIT */
gemtk_av_send(AV_EXIT, NULL, NULL);
}
if(va_helpbuf != NULL){
free(va_helpbuf);
va_helpbuf = NULL;
}
av_shell_id = -1;
}
bool gemtk_av_send (short message, const char * data1, const char * data2)
{
short msg[8];
short to_ap_id = av_shell_id;
/* - 100 to ap id would be no AV server */
if (to_ap_id == -100){
return false;
}
msg[0] = message;
msg[1] = gl_apid;
msg[7] = msg[6] = msg[5] = msg[4] = msg[3] = msg[2] = 0;
switch (message)
{
case AV_EXIT:
msg[3] = gl_apid;
break;
case AV_PROTOKOLL:
msg[3] = VV_START | VV_ACC_QUOTING;
*(char **)(msg+6) = strcpy (va_helpbuf, av_clientname);
break;
case AV_STARTPROG:
DEBUG_PRINT(("AV_STARTPROG: %s (%s)\n", data1, data2));
*(char **)(msg+3) = strcpy(va_helpbuf, data1);
*(char **)(msg+5) = strcpy(va_helpbuf, data2);
break;
case AV_VIEW:
DEBUG_PRINT(("AV_VIEW: %s (%d)\n", data1, (short)data2));
*(char **)(msg+3) = strcpy(va_helpbuf, data1);
msg[5] = (short)data2;
break;
default:
return false; /* not supported */
}
return (appl_write (to_ap_id, 16, msg) > 0);
}
bool gemtk_av_dispatch (short msg[8])
{
if(av_shell_id == -1)
return(false);
switch (msg[0]) {
case VA_PROTOSTATUS :
DEBUG_PRINT(("AV STATUS: %d for %d\n", msg[3], msg[1]));
if (msg[1] == av_shell_id) {
av_shell_status = msg[3];
if(av_shell_status & AA_STARTPROG){
printf(" AA_STARTPROG\n");
}
}
break;
default:
DEBUG_PRINT(("Unknown AV message: %d", msg[0]));
break;
}
return(true);
}

121
atari/gemtk/vaproto.h Normal file
View File

@ -0,0 +1,121 @@
#ifndef VAPROTO_H_INCLUDED
#define VAPROTO_H_INCLUDED
#define VAPRO 1
/* AES-Messages */
typedef enum
{
AV_PROTOKOLL = 0x4700,
VA_PROTOSTATUS = 0x4701,
AV_GETSTATUS = 0x4703,
AV_STATUS = 0x4704,
VA_SETSTATUS = 0x4705,
AV_SENDKEY = 0x4710,
VA_START = 0x4711,
AV_ASKFILEFONT = 0x4712,
VA_FILEFONT = 0x4713,
AV_ASKCONFONT = 0x4714,
VA_CONFONT = 0x4715,
AV_ASKOBJECT = 0x4716,
VA_OBJECT = 0x4717,
AV_OPENCONSOLE = 0x4718,
VA_CONSOLEOPEN = 0x4719,
AV_OPENWIND = 0x4720,
VA_WINDOPEN = 0x4721,
AV_STARTPROG = 0x4722,
VA_PROGSTART = 0x4723,
AV_ACCWINDOPEN = 0x4724,
VA_DRAGACCWIND = 0x4725,
AV_ACCWINDCLOSED = 0x4726,
AV_COPY_DRAGGED = 0x4728,
VA_COPY_COMPLETE = 0x4729,
AV_PATH_UPDATE = 0x4730,
AV_WHAT_IZIT = 0x4732,
VA_THAT_IZIT = 0x4733,
AV_DRAG_ON_WINDOW = 0x4734,
VA_DRAG_COMPLETE = 0x4735,
AV_EXIT = 0x4736,
AV_STARTED = 0x4738,
VA_FONTCHANGED = 0x4739,
AV_XWIND = 0x4740,
VA_XOPEN = 0x4741,
/* Neue Messages seit dem 26.06.1995 */
AV_VIEW = 0x4751,
VA_VIEWED = 0x4752,
AV_FILEINFO = 0x4753,
VA_FILECHANGED = 0x4754,
AV_COPYFILE = 0x4755,
VA_FILECOPIED = 0x4756,
AV_DELFILE = 0x4757,
VA_FILEDELETED = 0x4758,
AV_SETWINDPOS = 0x4759,
VA_PATH_UPDATE = 0x4760,
VA_HIGH /* HR please always do this! */
} AV_VA;
/* Objekttypen fr VA_THAT_IZIT */
enum
{
VA_OB_UNKNOWN,
VA_OB_TRASHCAN,
VA_OB_SHREDDER,
VA_OB_CLIPBOARD,
VA_OB_FILE,
VA_OB_FOLDER,
VA_OB_DRIVE,
VA_OB_WINDOW,
VA_OB_NOTEPAD,
VA_OB_NOTE
};
typedef enum
{
VV_SETSTATUS = 0x0001,
VV_START = 0x0002,
VV_STARTED = 0x0004,
VV_FONTCHANGED = 0x0008,
VV_ACC_QUOTING = 0x0010,
VV_PATH_UPDATE = 0x0020
} av_va_give;
typedef enum
{ /* mp[3]: */
AA_SENDKEY = 0x0001, /* b0: MAGXDESK, THING */
AA_ASKFILEFONT = 0x0002, /* b1: THING */
AA_ASKCONFONT = 0x0004, /* b2: THING */
AA_ASKOBJECT = 0x0008,
AA_OPENWIND = 0x0010, /* b4: MAGXDESK, THING */
AA_STARTPROG = 0x0020, /* b5: MAGXDESK, THING */
AA_ACCWIND = 0x0040, /* b6: THING */
AA_STATUS = 0x0080, /* b7: THING */
AA_COPY_DRAGGED= 0x0100, /* b8: THING */
AA_DRAG_ON_WINDOW=0x0200, /* b9: MAGXDESK, THING */
AA_EXIT = 0x0400, /* b10: MAGXDESK, THING */
AA_XWIND = 0x0800, /* b11: MAGXDESK, THING */
AA_FONTCHANGED = 0x1000, /* b2: THING */
AA_STARTED = 0x2000, /* b13: MAGXDESK, THING */
AA_SRV_QUOTING = 0x4000, /* b14: THING */
AA_FILE = 0x8000, /* b15: THING */
/* mp[4]: THING */
AA_COPY = 0x0001,
AA_DELETE = 0x0002,
AA_VIEW = 0x0004,
AA_SETWINDPOS = 0x0008,
AA_COPYFILELINK= 0x0010,
AA_SENDCLICK = 0x0020
} av_va_have;
/* Makros zum Testen auf Quoting */
#define VA_ACC_QUOTING(a) ((a) & VV_ACC_QUOTING)
#define VA_SERVER_QUOTING(a) ((a) & AA_SRV_QUOTING)
#endif // VAPROTO_H_INCLUDED