コード例 #1
0
ファイル: framemgr.cpp プロジェクト: ErisBlastar/osfree
/* Create general Window */
extern "C" HWND    APIENTRY Win32CreateWindow(HWND hwndParent,
                                 PCSZ  pszClass,
                                 PCSZ  pszName,
                                 ULONG flStyle,
                                 LONG x,
                                 LONG y,
                                 LONG nx,
                                 LONG ny,
                                 HWND hwndOwner,
                                 HWND hwndInsertBehind,
                                 ULONG id,
                                 PVOID pCtlData,
                                 PVOID pPresParams)
{
  HAB iHab;
  HWND hwnd=NULL;
  FPM_Window *pw;
  int len,rc;

  iHab = _hab.GetCurrentHAB();
    if(iHab < 0)
    {  //_hab.SetError(ihab - bad! , PMERR_INVALID_HAB);
       debug(3, 0)("WARNING: __FUNCTION__: bad ihab %x\n",iHab);
       _fatal("Thread don't initialized to FreePM");
       return NULL;
    }

//create hwndClient
    rc = F_SendCmdToServer(client_obj, F_CMD_WINCREATE_HWND, iHab);
    if(rc)
    {  if(rc == ERROR_BROKEN_PIPE)
       {      /* todo: attempt to reconnect till timeout */
       }
       debug(3, 0)("WARNING:__FUNCTION__:SendCmdToServer Error: %s\n",rc);
       _fatal("SendCmdToServer Error\n");
    }

    rc = F_RecvDataFromServer(client_obj, &hwnd, &len, sizeof(HWND));
    if(rc)
    {  if(rc == ERROR_BROKEN_PIPE)
       {      /* todo: attempt to reconnect till timeout */
       }
       debug(3, 0)("WARNING:__FUNCTION__:RecvDataFromServer Error: %s\n",rc);
       _fatal("RecvDataFromServer Error\n");
    }

    pw = new FPM_Window();
    pw->CreateFPM_Window(hwndParent,  /*  Parent-window handle. */
                        pszClass,    /*  Registered-class name. */
                        pszName,     /*  Window text. */
                        flStyle,     /*  Window style. */
                        x,           /*  x-coordinate of window position. */
                        y,           /*  y-coordinate of window position. */
                        nx,          /*  Width of window, in window coordinates. */
                        ny,          /*  Height of window, in window coordinates. */
                        hwndOwner,   /*  Owner-window handle. */
                        hwndInsertBehind, /*  Sibling-window handle. */
                        id,          /*  Window resource identifier. */
                        pCtlData,    /*  Pointer to control data. */
                        pPresParams);/*  Presentation parameters. */

//    _hab.AddHwnd(hwnd,iHab, pw);

    return hwnd;
}
コード例 #2
0
// the callback in the server called by a communication backend
// on each comm. protocol command
void handler (ULONG obj, int ncmd, int data, int threadNum)
{
    int  rc, l, len;
    char buf[256];

    switch(ncmd)
    {
    case F_CMD_GET_IHAB:
    {
        int iHAB = 1, inf[2];
        static int iClientId = 1;
        debug(0, 2)("Fs_ClientWork: F_CMD_GET_IHAB not yet full implemented\n");
        iClientId++;
        iHAB = session.hab_list.Add(iClientId ,threadNum);
        inf[0] = iHAB;
        inf[1] = iClientId;
        rc=  F_SendDataToClient(obj, inf , sizeof(inf));
    }
    break;
    case F_CMD_CLIENT_EXIT:
//todo: clear ihab = data
        debug(0, 2) ("Fs_ClientWork: F_CMD_CLIENT_EXIT %x ; not yet implemented\n", data);
        break;
    case F_CMD_WINPOSTMSG:
    {   SQMSG sqmsg;
        int rc1,ihabto;
        rc = F_RecvDataFromClient(obj, &sqmsg, &l, sizeof(SQMSG));
        debug(0, 2) ("Fs_ClientWork: F_CMD_WINPOSTMSG get %i bytes\n",l);
        if(rc == 0 && l == sizeof(SQMSG))
        {   rc1 = _WndList.QueryHab(sqmsg.qmsg.hwnd, ihabto);
            if(rc1 == 1)
            {   sqmsg.ihto = ihabto;
                rc  = session.hab_list.Queue.Add(&sqmsg);
            }
        }
    }
    break;
    case F_CMD_WINSENDMSG:
    {   SQMSG sqmsg;
        int rc1,ihabto;
        rc = F_RecvDataFromClient(obj, &sqmsg, &l, sizeof(SQMSG));
        debug(0, 2) ("Fs_ClientWork: F_CMD_WINPOSTMSG get %i bytes\n",l);
        if(rc == 0 && l == sizeof(SQMSG))
        {   rc1 = _WndList.QueryHab(sqmsg.qmsg.hwnd, ihabto);
            if(rc1 == 1)
            {   sqmsg.ihto = ihabto;
//todo: it is sendmsg == postmsg implementation
//it seems that we must wait in client via call to CMD_WINQUERYPOSTED or smth like it
                rc  = session.hab_list.Queue.Add(&sqmsg);
            }
        }
    }
    break;

    case F_CMD_WINQUERY_MSG: /* Query messages for ihab = data */
    {
        int nmsg=0;
        int ihabto;
        ihabto = data;
        nmsg = session.hab_list.Queue.QueryNmsg(ihabto);
        if (nmsg)
            debug(0, 2) ("Fs_ClientWork: F_CMD_WINQUERY_MSG, nmsg=%i\n",nmsg);
        rc = F_SendDataToClient(obj, &nmsg , sizeof(int));
    }
    break;
    case F_CMD_WINGET_MSG:  /* Get message for ihab = data */
    {
        SQMSG sqmsg;
        int rc, ihabto;
        int nmsg=0;
        ihabto = data;
        rc = session.hab_list.Queue.GetForIhab(&sqmsg, ihabto);
        if (rc == 0) nmsg = 1;

        if (nmsg == 1)
            debug(0, 2) ("Fs_ClientWork: F_CMD_WINGET_MSG for %i, msg=%x\n", ihabto, sqmsg.qmsg.msg);
        else
            debug(0, 2) ("Fs_ClientWork: F_CMD_WINGET_MSG, No msg  for %i\n", ihabto);

        rc = F_SendDataToClient(obj, &nmsg , sizeof(int));

        if(nmsg)
            rc = F_SendDataToClient(obj, &sqmsg.qmsg , sizeof(QMSG));
    }
    break;

    case F_CMD_WINCREATE_HWND:
    {   HWND hwnd;
        int iHab;
        iHab = data;
        hwnd = _WndList.Add(iHab);
//todo: set _WndList with thread info and cleanup at thread(client exit) end
        rc=  F_SendDataToClient(obj, &hwnd , sizeof(HWND));
    }

    break;
    case F_CMD_WINSET_PARENT_HWND:
    {   HWND hwnd, hwndParent;
        hwnd = data;
        rc = F_RecvDataFromClient(obj, (void *)&hwndParent, &len, sizeof(HWND));
        rc = _WndList.SetParent(hwnd, hwndParent);
    }
    break;

    case F_CMD_GET_HPS:
    {   HWND hwnd;
        HPS hps;
        hwnd = data;
        hps = _WndList.GetHPS(hwnd);
        rc=  F_SendDataToClient(obj, &hps, sizeof(HPS));
    }
    break;
    case F_CMD_RELEASE_HPS:
    {
        HPS hps;
        int rc1;
        hps = data;
        rc1 = _WndList.ReleaseHPS(hps);
        rc=  F_SendDataToClient(obj, &rc1, sizeof(int));
    }
    break;
    case F_CMD_WIN_SET_WND_SIZE:
    {   HWND hwnd = data;
        int par[2],rc1;
        rc = F_RecvDataFromClient(obj, (void *)&par[0], &len, sizeof(int)*2);
        rc1 = 0;
        //todo
        rc=  F_SendDataToClient(obj, &rc1, sizeof(int));
    }
    break;

    case F_CMD_WIN_SET_WND_POS:
    {   HWND hwnd = data;
        int par[2],rc1;
        rc = F_RecvDataFromClient(obj, (void *)&par[0], &len, sizeof(int)*2);
        rc1 = 0;
        //todo
        rc=  F_SendDataToClient(obj, &rc1, sizeof(int));
    }
    break;

    case F_CMD_WIN_GET_WND_SWP:
    {   HWND hwnd = data;
        SWP swp;
        //todo
        rc=  F_SendDataToClient(obj, &swp, sizeof(SWP));
    }
    break;

    case F_CMD_WIN_SHOW:
    {   HWND hwnd = data;
        int par,rc1;
        rc = F_RecvDataFromClient(obj, (void *)&par, &len, sizeof(int));
        rc1 = 0;
        //todo
        rc=  F_SendDataToClient(obj, &rc1, sizeof(int));
    }
    break;

    case F_CMD_GPI_SET_COLOR:
    {   HPS hps;
        int color, len, rc1=FALSE;
        hps = data;
        rc = F_RecvDataFromClient(obj, (void *)&color, &len, sizeof(int));
        debug(0, 0) ("F_CMD_GPI_SET_COLOR: get hps=%x, color=%x, len=%i\n",hps,color,len);
        if(hps >= 0 && hps < _WndList.numPS)
        {   if(_WndList.pPS[hps].used)
                /* rc1 = F_GpiSetColor(&_WndList.pPS[hps], color); */
                rc1 = F_PS_GpiSetColor(&_WndList.pPS[hps], color);
        }
        rc=  F_SendDataToClient(obj, &rc1, sizeof(int));
    }
    break;
    case F_CMD_GPI_MOVE:
    {   HPS hps;
        int rc1=FALSE;
        POINTL Point;
        hps = data;
        rc = F_RecvDataFromClient(obj, (void *)&Point, &len, sizeof(POINTL));
        debug(0, 0) ("F_CMD_GPI_MOVE: get hps=%x,len=%i\n",hps,len);

        if(hps >= 0 && hps < _WndList.numPS)
        {   if(_WndList.pPS[hps].used)
                rc1 = F_PS_GpiMove(&_WndList.pPS[hps], &Point);
        }
        rc=  F_SendDataToClient(obj, &rc1, sizeof(int));
    }
    break;
    case F_CMD_GPI_LINE:
    {   HPS hps;
        int rc1=FALSE;
        POINTL Point;
        hps = data;
        rc = F_RecvDataFromClient(obj, (void *)&Point, &len, sizeof(POINTL));

        if(hps >= 0 && hps < _WndList.numPS)
        {   if(_WndList.pPS[hps].used)
                rc1 = F_PS_GpiLine(&_WndList.pPS[hps], &Point);
        }
        rc=  F_SendDataToClient(obj, &rc1, sizeof(int));
    }
    break;
    case F_CMD_GPI_DRAW_LINE:
//TODO
        break;
    case F_CMD_GPI_DRAW_RECT:
//TODO
        break;
    case F_CMD_DB_PRINT:
    {
        F_RecvDataFromClient(obj, (char *)buf, &len, sizeof(buf));
        _db_print(buf);
    }
    break;
    case F_CMD_FATAL_COMMON:
        F_RecvDataFromClient(obj, (char *)buf, &len, sizeof(buf));
        _fatal_common(buf);
        break;

#define POKA 0
#if POKA
    case 1:
        debug(0, 2) ("Fs_ClientWork: Get ncmd %x %x\n", ncmd, data);
        rc=F_SendCmdToServer(obj, ncmd, data);
        switch(data)
        {
        case S_SHUTDOWN:
//                 squid_signal(SIGTERM, shut_down, SA_NODEFER | SA_RESETHAND | SA_RESTART);
//            debug(0, 0) ("squid_signal:\n");
            DosSleep(100);
            rc = raise(SIGTERM);
//            debug(0, 0) ("raise: rc =%x %s\n",rc,xstdio_strerror());
            break;
        case S_RECONFIGURE:
//                       do_reconfigure = 1;
            break;
        case S_ROTATE:
//                       do_rotate = 1;
            break;
        case S_DEBUG:
            break;
        case S_KILL:
            debug(1, 1) ("Preparing for killing\n");
//               do_shutdown++;
//           SquidShutdown(NULL);
            break;
        }
        ncmd = 0;
        break;
#endif
    //POKA
    default:
        debug(0, 2) ("Fs_ClientWork:WARNING: Unimplemented cmd %x\n", ncmd);
        ncmd = 0;
        break;

    } //endof switch(ncmd)
}