home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / taman002.zip / TASKMANA.ZIP / src / kProcessDetailsPage.cpp < prev    next >
C/C++ Source or Header  |  2000-04-29  |  7KB  |  229 lines

  1. /* $Id: kProcessDetailsPage.cpp,v 1.1 2000/04/29 19:06:35 stknut Exp $
  2.  *
  3.  * Process Detail Page.
  4.  *
  5.  * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
  6.  *
  7.  */
  8. /*******************************************************************************
  9. *   Defined Constants And Macros                                               *
  10. *******************************************************************************/
  11. #define INCL_DOS
  12. #define INCL_DOSERRORS
  13. #define INCL_WIN
  14.  
  15.  
  16. /*******************************************************************************
  17. *   Header Files                                                               *
  18. *******************************************************************************/
  19. #include <os2.h>
  20. #ifdef USE_KLIB
  21.     #include <kAssert.h>
  22.     #include <kLog.h>
  23.     #include <kHeap.h>
  24. #endif
  25. #include <stdio.h>
  26. #include <string.h>
  27.  
  28. #include "kBase.h"
  29. #include "kError.h"
  30. #include "kDlgBase.h"
  31. #include "kMenuBase.h"
  32. #include "kContainer.h"
  33. #include "kNotebookBase.h"
  34. #include "kNotebookPageBase.h"
  35.  
  36. #include "kQuerySysState.h"
  37. #include "kDetailBase.h"
  38.  
  39. #include "kObjectRecord.h"
  40. #include "kProcessRecord.h"
  41. #include "kProcessContainer.h"
  42. #include "kThreadRecord.h"
  43. #include "kThreadContainer.h"
  44. #include "kProcessDetailsPage.h"
  45. #include "kProcessDetails.h"
  46. #include "kTaskMgr_Defs.h"
  47. #include "kTaskMgr.h"
  48.  
  49.  
  50.  
  51. VOID  kProcessDetailsPage::sysCommand(USHORT usCmd, USHORT usSource, BOOL fPointer) //WM_SYSCOMMAND
  52. {
  53.     ASSERT(FALSE);
  54.     kDlgBase::sysCommand(usCmd, usSource, fPointer);
  55. }
  56.  
  57. VOID  kProcessDetailsPage::close() //WM_CLOSE
  58. {
  59.     ASSERT(FALSE);
  60.     WinDefDlgProc(hwnd, WM_CLOSE, 0,0);
  61. }
  62.  
  63.  
  64. /**
  65.  * Displays the popup menu for the container.
  66.  * @param     usId     Container id.
  67.  * @param     pRecord  Pointer to the record which is selected by either the key
  68.  */
  69. VOID kProcessDetailsPage::cnrContextMenu(USHORT usId, PRECORDCORE pRecord)
  70. {
  71.     if (usId == KPROCDTLPG_CNR_CHILDREN)
  72.         pCnrChildren->cnrContextMenu(usId, pRecord);
  73.     else
  74.         pCnrThreads->cnrContextMenu(usId, pRecord);
  75.  
  76. }
  77.  
  78.  
  79. /**
  80.  * Enter or double click on record in the container.
  81.  * This action will bring up the detail dialog for the record.
  82.  */
  83. VOID kProcessDetailsPage::cnrEnter(USHORT usId, HWND hwndCnr, PRECORDCORE pRecord, ULONG fKey)
  84. {
  85.     if (usId == KPROCDTLPG_CNR_CHILDREN)
  86.         pCnrChildren->cnrEnter(usId, hwndCnr, pRecord, fKey);
  87.     else
  88.         pCnrThreads->cnrEnter(usId, hwndCnr, pRecord, fKey);
  89. }
  90.  
  91.  
  92. /**
  93.  * WM_DESTROY.
  94.  * We'll simply delete this object.
  95.  */
  96. VOID  kProcessDetailsPage::destroy()
  97. {
  98.     delete this;
  99. }
  100.  
  101.  
  102. /**
  103.  * Module detail dialog.
  104.  * @param     pNtbk     Pointer to notebook.
  105.  * @param     usPid     Process ID of the process to show details for.
  106.  */
  107. kProcessDetailsPage::kProcessDetailsPage(kNotebookBase *pNtbk, USHORT usPid)
  108. : kNotebookPageBase(DL_KPROCESSDETAILSPAGE, NULLHANDLE, pNtbk),
  109.     pCnrThreads(NULL), pCnrChildren(NULL), usPid(usPid)
  110. {
  111.     PPROCESSDATA pProcData;
  112.  
  113.     /*
  114.      *  Get process data.
  115.      */
  116.     pProcData = QSGetProcessData(usPid);
  117.     if (pProcData == NULL)
  118.         throw(kError(ERROR_INVALID_PARAMETER, kError::dos));
  119.  
  120.  
  121.     /*
  122.      * Create the two containers
  123.      */
  124.     pCnrThreads     = new kThreadContainer(hwnd, KPROCDTLPG_CNR_THREADS, usPid);
  125.     pCnrChildren    = new kProcessContainer(hwnd, KPROCDTLPG_CNR_CHILDREN, usPid);
  126.  
  127.     /*
  128.      * Set dialog content
  129.      */
  130.     update();
  131.  
  132. }
  133.  
  134.  
  135. /**
  136.  * Destructor stub.
  137.  */
  138. kProcessDetailsPage::~kProcessDetailsPage()
  139. {
  140.     if (pCnrThreads)
  141.         delete pCnrThreads;
  142.     if (pCnrChildren)
  143.         delete pCnrChildren;
  144. }
  145.  
  146.  
  147.  
  148. /**
  149.  * Updates the content of this notebook page.
  150.  * @returns   Successindicator.
  151.  * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
  152.  * @remark
  153.  */
  154. BOOL kProcessDetailsPage::update()
  155. {
  156.     CHAR            szBuffer[512];
  157.     PPROCESSDATA    pProcData;
  158.     qsLrec_t *      pMteRec;
  159.     PSZ             psz;
  160.  
  161.     /*
  162.      *  Get process data.
  163.      */
  164.     pProcData = QSGetProcessData(usPid);
  165.     if (pProcData == NULL)
  166.         throw(kError(ERROR_INVALID_PARAMETER, kError::dos));
  167.  
  168.     /*
  169.      * Find hMte record
  170.      */
  171.     pMteRec = QSGetMteData(pProcData->pProcRec->hMte);
  172.     if (pMteRec == NULL)
  173.         throw(kError(ERROR_INVALID_PARAMETER, kError::dos));
  174.  
  175.     /*
  176.      * Set Dialog itmes.
  177.      */
  178.     setDlgItemText(KPROCDTLPG_TXT_NAME        , "%s",       pMteRec->pName);
  179.     setDlgItemText(KPROCDTLPG_TXT_PID         , "0x%04x",   pProcData->pProcRec->pid);
  180.     setDlgItemText(KPROCDTLPG_TXT_PPID        , "0x%04x",   pProcData->pProcRec->ppid);
  181.     setDlgItemText(KPROCDTLPG_TXT_HMTE        , "0x%04x",   pProcData->pProcRec->hMte);
  182.     switch (pProcData->pProcRec->type)
  183.     {
  184.         case 0: psz = "FullScr (%d)"; break;
  185.         case 1: psz = "VDM (%d)"; break;
  186.         case 2: psz = "VIO (%d)"; break;
  187.         case 3: psz = "PM (%d)"; break;
  188.         case 4: psz = "Detach (%d)"; break;
  189.         default:psz = "unknown (%d)"; break;
  190.  
  191.     }
  192.     setDlgItemText(KPROCDTLPG_TXT_TYPE        , psz,        pProcData->pProcRec->type);
  193.     psz = szBuffer;
  194.     psz[0] = '\0';
  195.     if (pProcData->pProcRec->stat & 0x01)
  196.         strcat(psz, "ExitList ");
  197.     if (pProcData->pProcRec->stat & 0x02)
  198.         strcat(psz, "ExitingThread1 ");
  199.     if (pProcData->pProcRec->stat & 0x04)
  200.         strcat(psz, "ExitingAll ");
  201.     if (pProcData->pProcRec->stat & 0x10)
  202.         strcat(psz, "SyncParent ");
  203.     if (pProcData->pProcRec->stat & 0x20)
  204.         strcat(psz, "WaitParent ");
  205.     if (pProcData->pProcRec->stat & 0x40)
  206.         strcat(psz, "Dying ");
  207.     if (pProcData->pProcRec->stat & 0x80)
  208.         strcat(psz, "Embryonic ");
  209.     if (pProcData->pProcRec->stat == 0)
  210.         strcat(psz, "Normal ");
  211.     setDlgItemText(KPROCDTLPG_TXT_STATUS      , "%s(%#0x)",  psz, pProcData->pProcRec->stat);
  212.     setDlgItemText(KPROCDTLPG_TXT_CTHREADS    , "%d",       pProcData->pProcRec->cTCB);
  213.     setDlgItemText(KPROCDTLPG_TXT_C32SEMAPHORS, "%d",       pProcData->pProcRec->c32PSem);
  214.     setDlgItemText(KPROCDTLPG_TXT_CSHAREDMEM  , "%d",       pProcData->pProcRec->cShrMem);
  215.     setDlgItemText(KPROCDTLPG_TXT_CFILES      , "%d",       pProcData->pProcRec->cFH);
  216.     setDlgItemText(KPROCDTLPG_TXT_CDLLS       , "%d",       pProcData->pProcRec->cLib);
  217.     setDlgItemText(KPROCDTLPG_TXT_SCREENGRPID , "0x%04x",   pProcData->pProcRec->sgid);
  218.     setDlgItemText(KPROCDTLPG_TXT_CCHILDREN   , "%d",       pCnrChildren->getCountOfRecords());
  219.  
  220.     /*
  221.      * Fill the containers.
  222.      */
  223.     pCnrThreads->update();
  224.     pCnrChildren->update();
  225.  
  226.  
  227.     return TRUE;
  228. }
  229.