/*
File: LCDWSERV.C

Methods for Class: lcdwserv    (Superclass: wserv).
*/

#include <lcdtest.g>
#include <hwim.h>
#include <help.g>
#include <olib.h>
#include <epoc.h>
#include <p_file.h>
#include <lcdwserv.g>
#include <lcdview.g>
#include <lcdtest.rsg>

GLREF_D PR_HWIMMAN  *w_am;
GLREF_D UBYTE       *DatUsedPathNamePtr;
GLREF_D UBYTE       *DatCommandPtr;
GLREF_D PR_LCDVIEW  *DatApp3;   /* Main Client Window   */

LOCAL_C VOID lLoadOwnVersionText(TEXT *pb)
    {
    ImgHeader head;
    VOID *pcb;
    INT val;

    f_open(&pcb,(TEXT *)DatCommandPtr,P_FOPEN|P_FSHARE|P_FSTREAM);
    val = p_read(pcb,&head,sizeof(head));
    p_close(pcb);
    if(val != sizeof(head))
        p_leave(E_FILE_INVALID);
    p_atos(pb,"%u.%03x",head.CodeVersion>>12,head.CodeVersion&0xfff);
    }

#pragma METHOD_CALL

METHOD VOID lcdwserv_ws_dyn_init(PR_LCDWSERV *self)
    {
    /* create and initialise the client window */
    p_send2(DatApp3=(PR_LCDVIEW *)f_new(CAT_LCDTEST_LCDTEST,C_LCDVIEW),O_WN_INIT);
    self->wserv.cli =(PR_WIN *)DatApp3;

    self->wserv.help_index_id = H_HELP;
    hInitVis(self->wserv.cli);
    hInfoPrint(S_COPYRIGHT);
    }

METHOD VOID lcdwserv_ws_do_help(PR_LCDWSERV *self,INT start_id)
    {
    TEXT *pTxt;        /* points into Help screen title buffer */

    p_supersend3(self,O_WS_DO_HELP,start_id);
    if (start_id!=H_HELP)
        return;
    pTxt=(&((PR_HELPDLG *)self->wserv.dial)->helpdlg.listbox->helplist.title[0]);
    pTxt += p_slen(pTxt)-5;     /* position back before 1.23w */
    lLoadOwnVersionText(pTxt);
    }
