You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by mt...@apache.org on 2003/10/01 20:06:20 UTC

cvs commit: jakarta-commons/daemon/src/native/nt/procrun procgui.c procrun.c procrun.h procrun.rc

mturk       2003/10/01 11:06:20

  Modified:    daemon/src/native/nt/procrun procgui.c procrun.c procrun.h
                        procrun.rc
  Log:
  Move the list view back to procrun.
  Move the generic spash back to procrun.
  Implement the callback parser for stdout messages.
  
  Revision  Changes    Path
  1.6       +133 -18   jakarta-commons/daemon/src/native/nt/procrun/procgui.c
  
  Index: procgui.c
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/daemon/src/native/nt/procrun/procgui.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- procgui.c	29 Sep 2003 08:56:50 -0000	1.5
  +++ procgui.c	1 Oct 2003 18:06:20 -0000	1.6
  @@ -130,11 +130,111 @@
   static char            *ac_stdout_lines[MAX_LISTCOUNT + 1];
   char                   *ac_cmdline;
   char                   *ac_cmdname;
  +char                   *ac_splash_msg = NULL;
  +
   RECT                   ac_winpos = {-1, 0, 640, 480};
  +static HWND            ac_splash_hwnd = NULL;
  +static HWND            ac_splist_hwnd;
  +
  +int                    ac_lview_current = 0;
  +
  +prcrun_lview_t lv_columns[] = {
  +    {   "Status",   60      },
  +    {   "Message",  552     },
  +    {   NULL,       0       },
  +};
   
  +prcrun_lview_t *ac_columns = &lv_columns[0];
   
   INT_PTR ac_show_properties(HWND owner);
   
  +static void lv_create_view(HWND hdlg, LPRECT pr, LPRECT pw)
  +{
  +    LV_COLUMN lvc;
  +    int i = 0;
  +    HIMAGELIST  imlist;
  +    HICON hicon;
  +    prcrun_lview_t *col = ac_columns;
  +
  +    imlist = ImageList_Create(16, 16, ILC_COLORDDB | ILC_MASK, 3, 0);
  +    hicon = LoadImage(ac_instance, MAKEINTRESOURCE(IDI_ICOI),
  +                      IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
  +    ImageList_AddIcon(imlist, hicon);
  +    hicon = LoadImage(ac_instance, MAKEINTRESOURCE(IDI_ICOW),
  +                      IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
  +    ImageList_AddIcon(imlist, hicon);
  +    hicon = LoadImage(ac_instance, MAKEINTRESOURCE(IDI_ICOS),
  +                      IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
  +    ImageList_AddIcon(imlist, hicon);
  +    
  +    ac_list_hwnd = CreateWindowEx(0L, WC_LISTVIEW, "", 
  +                                  WS_VISIBLE | WS_CHILD |
  +                                  LVS_REPORT | WS_EX_CLIENTEDGE,
  +                                  0, 0, pr->right - pr->left,
  +                                  pr->bottom - abs((pw->top - pw->bottom)),
  +                                  hdlg, NULL, ac_instance, NULL);
  +    lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  +    lvc.fmt  = LVCFMT_LEFT;
  +    
  +    ListView_SetImageList(ac_list_hwnd,imlist, LVSIL_SMALL);
  +    
  +    while (col->label)  {
  +        lvc.iSubItem    = i;
  +        lvc.cx          = col->width;
  +        lvc.pszText     = col->label;
  +        ListView_InsertColumn(ac_list_hwnd, i, &lvc );
  +        ++col;
  +        ++i;
  +    }
  +#ifdef LVS_EX_FULLROWSELECT
  +    ListView_SetExtendedListViewStyleEx(ac_list_hwnd, 0,
  +        LVS_EX_FULLROWSELECT |
  +        LVS_EX_INFOTIP);
  +#endif
  +    
  +}
  +
  +static int  ac_lv_iicon = 0;
  +
  +
  +void parse_list_string(const char *str)
  +{
  +    int row = 0x7FFFFFFF;
  +    LV_ITEM lvi;
  +
  +    if (str) {
  +        if (STRN_COMPARE(str, "INFO:")) {
  +            ac_lv_iicon = 0;
  +        }
  +        else if (STRN_COMPARE(str, "WARNING:")) {
  +            ac_lv_iicon = 1;
  +        }
  +        else if (STRN_COMPARE(str, "ERROR:")) {
  +            ac_lv_iicon = 2;
  +        }
  +        else if (STRN_COMPARE(str, "SEVERE:")) {
  +            ac_lv_iicon = 2;
  +        }
  +    }
  +
  +    memset(&lvi, 0, sizeof(LV_ITEM));
  +    lvi.mask        = LVIF_IMAGE | LVIF_TEXT;
  +    lvi.iItem       = ac_lview_current;
  +    lvi.iImage      = ac_lv_iicon;
  +    lvi.pszText     = "";
  +    lvi.cchTextMax  = 0;
  +    row = ListView_InsertItem(ac_list_hwnd, &lvi);
  +    if (row == -1)
  +        return;
  +    ListView_SetItemText(ac_list_hwnd, row, 1, (char *)str);
  +    ListView_EnsureVisible(ac_list_hwnd,
  +                               ListView_GetItemCount(ac_list_hwnd) - 1,
  +                               FALSE); 
  +
  +    ac_lview_current++;
  +}
  +
  +lv_parse_cb_t  lv_parser = parse_list_string;
   
   void ac_show_try_icon(HWND hwnd, DWORD message, const char *tip, int stop)
   {
  @@ -171,10 +271,17 @@
       int i;
   
       if (str) {
  +        if (ac_splash_hwnd) {
  +            if (ac_splash_msg && 
  +                !strnicmp(str, ac_splash_msg, strlen(ac_splash_msg))) {
  +                ac_show_try_icon(ac_main_hwnd, NIM_MODIFY, ac_cmdname, 0);
  +                EndDialog(ac_splash_hwnd, TRUE);
  +                ac_splash_hwnd = NULL;
  +            }
  +            else
  +                SendMessage(ac_splist_hwnd, LB_INSERTSTRING, 0, (LPARAM)str);
  +        }
   
  -#if defined(PRCRUN_EXTENDED)
  -        acx_process_splash(str);
  -#endif
           if (nqueue > MAX_LISTCOUNT - 1) {
               free(ac_stdout_lines[0]);
               /* TODO: improve performance */
  @@ -187,16 +294,14 @@
       }
       if (!ac_list_hwnd || !nqueue)
           return;
  -#if defined(PROCRUN_EXTENDED)
       if (ac_use_lview) {
           for (i = 0; i < nqueue; i++) {
  -            acx_parse_list_string(ac_stdout_lines[i]);
  +            (*lv_parser)(ac_stdout_lines[i]);
               if (litems++ > MAX_LIST_ITEMS)
                   ListView_DeleteItem(ac_list_hwnd, 0);
           }
       }
       else 
  -#endif
       {
           for (i = 0; i < nqueue; i++) {
               ListBox_AddString(ac_list_hwnd, ac_stdout_lines[i]);
  @@ -443,14 +548,11 @@
                           
              GetWindowRect(status_bar, &r);
              GetClientRect(hdlg, &m);
  -#if defined(PROCRUN_EXTENDED)
              if (!ac_use_lview)
                  MoveWindow(ac_list_hwnd, 0, 0, m.right - m.left, m.bottom - abs((r.top - r.bottom)), TRUE);
              else
  -               acx_create_view(hdlg, &m, &r);
  -#else
  -           MoveWindow(ac_list_hwnd, 0, 0, m.right - m.left, m.bottom - abs((r.top - r.bottom)), TRUE);
  -#endif
  +               lv_create_view(hdlg, &m, &r);
  +
              ac_add_list_string(NULL, 0);
              break;
           case WM_SIZE:
  @@ -935,6 +1037,20 @@
   }
   
   
  +LRESULT CALLBACK ac_splash_dlg_proc(HWND hdlg, UINT message, WPARAM wparam, LPARAM lparam)
  +{
  +
  +    switch (message) {
  +        case WM_INITDIALOG:
  +           ac_splash_hwnd = hdlg;
  +           ac_center_window(hdlg);
  +           ac_splist_hwnd = GetDlgItem(hdlg, IDL_INFO); 
  +           break;
  +    }
  +
  +    return FALSE;
  +}
  +
   
   LRESULT CALLBACK ac_main_wnd_proc(HWND hwnd, UINT message,
                             WPARAM wparam, LPARAM lparam)
  @@ -958,10 +1074,10 @@
                * if something goes wrong.
                */
               SetTimer(hwnd, WM_TIMER_TIMEOUT, TIMEOUT_TIME, NULL);
  -
  -#if defined(PROCRUN_EXTENDED)
  -            acx_create_spash(hwnd);
  -#endif
  +            if (ac_use_try) {
  +                DialogBox(ac_instance, MAKEINTRESOURCE(IDD_DLGSPLASH),
  +                    hwnd, (DLGPROC)ac_splash_dlg_proc);
  +            }
               if (ac_use_show) {
                   DialogBox(ac_instance, MAKEINTRESOURCE(IDD_DLGCONSOLE),
                             hwnd, (DLGPROC)ac_console_dlg_proc);
  @@ -972,9 +1088,8 @@
                   case WM_TIMER_TIMEOUT:
                       if (ac_use_try)
                           ac_show_try_icon(hwnd, NIM_MODIFY, ac_cmdname, 0);
  -#if defined(PROCRUN_EXTENDED)
  -                    acx_close_spash();
  -#endif
  +                    if (ac_use_try && ac_splash_hwnd)
  +                        EndDialog(ac_splash_hwnd, TRUE);
                   break;
               }
               break;
  
  
  
  1.6       +1 -0      jakarta-commons/daemon/src/native/nt/procrun/procrun.c
  
  Index: procrun.c
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/daemon/src/native/nt/procrun/procrun.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- procrun.c	29 Sep 2003 08:56:50 -0000	1.5
  +++ procrun.c	1 Oct 2003 18:06:20 -0000	1.6
  @@ -111,6 +111,7 @@
   static int g_is_windows_nt = 0;
   
   #ifdef PROCRUN_WINAPP
  +
   
   #endif
   
  
  
  
  1.5       +25 -11    jakarta-commons/daemon/src/native/nt/procrun/procrun.h
  
  Index: procrun.h
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/daemon/src/native/nt/procrun/procrun.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- procrun.h	29 Sep 2003 08:56:50 -0000	1.4
  +++ procrun.h	1 Oct 2003 18:06:20 -0000	1.5
  @@ -97,8 +97,13 @@
   #define IDC_RICHEDIT21        119
   #define IDM_ABOUT             120
   #define IDI_ICOCONTRYSTOP     121
  -
  -#define IDM_OPTIONS           122
  +#define IDB_BMPSPLASH         122
  +#define IDD_DLGSPLASH         123
  +#define IDL_INFO              124
  +#define IDI_ICOI              125
  +#define IDI_ICOS              126
  +#define IDI_ICOW              127
  +#define IDM_OPTIONS           128
   #define RC_DLG_SRVOPT         130
   #define RC_LBL_VER            131
   #define RC_LISTVIEW           132
  @@ -222,6 +227,7 @@
   #define STRN_SIZE(x) (sizeof(x) - 1)
   #define STRN_COMPARE(x, s) (strncmp((x), (s), sizeof((s)) -1) == 0)
   #define STRNI_COMPARE(x, s) (strnicmp((x), (s), sizeof((s)) -1) == 0)
  +#define STR_NOT_NULL(s) { if((s) == NULL) (s) = ""; }
   
       enum { 
           PROCRUN_MODE_WINAPP = 1,
  @@ -343,6 +349,11 @@
       void save_service_params(process_t *proc, char *java);
       pool_t *pool_create();
       int pool_destroy(pool_t *pool);
  +    
  +    typedef struct prcrun_lview_t {
  +        char *  label;
  +        DWORD   width;
  +    } prcrun_lview_t;
   
   #if !defined(PROCRUN_CONSOLE)
   
  @@ -354,23 +365,26 @@
   extern int  ac_use_show;
   extern int  ac_use_props;
   extern int  ac_use_lview;
  +extern int  ac_lview_current;
   
  -extern  RECT        ac_winpos;
  -extern  HINSTANCE   ac_instance;
  -extern  HWND        ac_main_hwnd;
  -extern  HWND        ac_list_hwnd;
  -extern  char        *ac_cmdname;
  +extern  RECT            ac_winpos;
  +extern  HINSTANCE       ac_instance;
  +extern  HWND            ac_main_hwnd;
  +extern  HWND            ac_list_hwnd;
  +extern  char            *ac_cmdname;
  +extern  char            *ac_splash_msg;
  +extern  prcrun_lview_t  *ac_columns;
   
   void    ac_show_try_icon(HWND hwnd, DWORD message, const char *tip, int stop);
   void    ac_center_window(HWND hwnd);
   
  +typedef void (*lv_parse_cb_t)(const char *data);
  +
  +extern lv_parse_cb_t    lv_parser;
  +
   #if defined(PROCRUN_EXTENDED)
   
  -void acx_process_splash(const char *str);
  -void acx_create_view(HWND hdlg, LPRECT pr, LPRECT pw);
   void acx_parse_list_string(const char *str);
  -void acx_create_spash(HWND hwnd);
  -void acx_close_spash();
   void acx_init_extended();
   
   
  
  
  
  1.4       +28 -1     jakarta-commons/daemon/src/native/nt/procrun/procrun.rc
  
  Index: procrun.rc
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/daemon/src/native/nt/procrun/procrun.rc,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- procrun.rc	29 Sep 2003 08:56:50 -0000	1.3
  +++ procrun.rc	1 Oct 2003 18:06:20 -0000	1.4
  @@ -59,15 +59,29 @@
   #include "procrun.h"
   #include "windows.h"
   
  -#if !defined(PROCRUN_EXTENDED)
  +#if !defined(EXT_ICOCONWRAP)
   IDI_ICOCONWRAP         ICON                    "proctry.ico"
  +#endif
  +#if !defined(EXT_ICOCONTRY)
   IDI_ICOCONTRY          ICON                    "proctry.ico"
  +#endif
  +#if !defined(EXT_ICOCONTRY)
   IDI_ICOCONTRYSTOP      ICON                    "proctry.ico"
   #endif
   
   IDR_RTFLIC             RTF                     "License.rtf"
   
   #ifdef _MSC_VER
  +#if !defined(EXT_BMPSPLASH)
  +IDB_BMPSPLASH          BITMAP   DISCARDABLE    "splash.bmp"
  +#endif
  +#endif
  +
  +IDI_ICOI               ICON                    "icoi.ico"
  +IDI_ICOS               ICON                    "icos.ico"
  +IDI_ICOW               ICON                    "icow.ico"
  +
  +#ifdef _MSC_VER
   IDB_BMPJAKARTA         BITMAP   DISCARDABLE    "jakarta-banner.bmp"
   IDR_CMENU MENUEX DISCARDABLE 
   BEGIN
  @@ -201,6 +215,19 @@
       PUSHBUTTON      "...",RC_BTN_STDE,298,102,18,12
   END
   
  +IDD_DLGSPLASH DIALOGEX 0, 0, 322, 151
  +STYLE DS_SYSMODAL | DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | 
  +    WS_BORDER
  +EXSTYLE WS_EX_TOPMOST
  +FONT 8, "Microsoft Sans Serif", 400, 0, 0x0
  +BEGIN
  +    LISTBOX         IDL_INFO,7,126,217,9, LBS_NOINTEGRALHEIGHT | 
  +                    LBS_NOSEL | NOT WS_BORDER | NOT LBS_USETABSTOPS
  +#ifdef _MSC_VER                    
  +    CONTROL         IDB_BMPSPLASH,IDC_STATIC,"Static",SS_BITMAP |
  +                    SS_CENTERIMAGE,0,0,322,151
  +#endif
  +END 
   
   1 VERSIONINFO
    FILEVERSION 2,1,1,0
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org