home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / fsrc1241.zip / request.c < prev    next >
C/C++ Source or Header  |  1999-02-14  |  36KB  |  1,060 lines

  1. /*---------------------------------------------------------------------------+
  2.  | Titel: REQUEST.C                                                          |
  3.  +-----------------------------------------+---------------------------------+
  4.  | Erstellt von: Michael Hohner            | Am: 18.10.1995                  |
  5.  +-----------------------------------------+---------------------------------+
  6.  | System: OS/2 2.x/3.x PM                                                   |
  7.  +---------------------------------------------------------------------------+
  8.  | Beschreibung:                                                             |
  9.  |                                                                           |
  10.  |   File-Requests v. FleetStreet                                            |
  11.  |                                                                           |
  12.  |                                                                           |
  13.  +---------------------------------------------------------------------------+
  14.  | Bemerkungen:                                                              |
  15.  +---------------------------------------------------------------------------*/
  16.  
  17. /*----------------------------- Header-Dateien ------------------------------*/
  18. #pragma strings(readonly)
  19.  
  20. #define INCL_PM
  21. #define INCL_BASE
  22. #include <os2.h>
  23. #include <string.h>
  24. #include <stdlib.h>
  25.  
  26. #include "main.h"
  27. #include "structs.h"
  28. #include "dialogids.h"
  29. #include "messages.h"
  30. #include "resids.h"
  31. #include "msgheader.h"
  32. #include "areaman\areaman.h"
  33. #include "utility.h"
  34. #include "dialogs.h"
  35. #include "setupdlg.h"
  36. #include "finddlg.h"
  37. #include "controls\editwin.h"
  38. #include "controls\listbox.h"
  39. #include "fltv7\fltv7.h"
  40. #include "lookups.h"
  41.  
  42. #include "request_manage.h"
  43. #include "request.h"
  44.  
  45. /*--------------------------------- Defines ---------------------------------*/
  46.  
  47. /*---------------------------------- Typen ----------------------------------*/
  48.  
  49. typedef struct
  50. {
  51.    PREQUESTPAR pRequestPar;
  52.    SIZEL MinSize;
  53.    PFILELIST pCurrentList;
  54.    FILELISTREAD ListRead;
  55.    int tidRead;
  56. } FREQUESTDATA, *PFREQUESTDATA;
  57.  
  58. typedef struct
  59. {
  60.    USHORT cb;
  61.    FILELIST FileList;
  62. } LISTADDPAR, *PLISTADDPAR;
  63.  
  64. typedef struct
  65. {
  66.    USHORT cb;
  67.    char pchFileName[LEN_REQFILE+1];
  68.    char pchPassword[LEN_PASSWORD+1];
  69. } FILEADDPAR, *PFILEADDPAR;
  70.  
  71. typedef struct
  72. {
  73.    USHORT cb;
  74.    char pchPassword[LEN_PASSWORD+1];
  75. } PASSWORDPAR, *PPASSWORDPAR;
  76.  
  77. /*---------------------------- Globale Variablen ----------------------------*/
  78.  
  79. extern HWND client, hwndhelp;
  80. extern HMODULE hmodLang;
  81. extern HAB anchor;
  82.  
  83. /*--------------------------- Funktionsprototypen ---------------------------*/
  84.  
  85. /*----------------------- interne Funktionsprototypen -----------------------*/
  86.  
  87. static void RefreshFileList(HWND hwndDlg, PFILELIST pList);
  88. static void FillFilesWindow(HWND hwndDlg, PRAMLIST pRAMList);
  89. static MRESULT EXPENTRY ListAddProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  90. static MRESULT EXPENTRY FileAddProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  91. static void AddFile(HWND hwndDlg);
  92. static PFILELIST QueryFileList(HWND hwndDlg);
  93. static void RemovePasswords(HWND hwnd);
  94. static void AddFileName(char *pchDest, char *pchName);
  95. static MRESULT EXPENTRY PasswordProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  96. static void SetPassword(HWND hwndDlg);
  97. static void SearchInFiles(HWND hwndDlg, BOOL bSearchNext);
  98. static void ActivateControls(HWND hwndDlg, BOOL bActivate);
  99. static void CreateRequest(HWND hwnd, PREQUESTPAR pRequestPar);
  100. static int LookupOtherLines(HWND hwnd);
  101.  
  102. /*-----------------------------------------------------------------------------
  103.  | Funktionsname:
  104.  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  105.  | Beschreibung:
  106.  |
  107.  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  108.  | Parameter:
  109.  |
  110.  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  111.  | Rückgabewerte:
  112.  |
  113.  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  114.  | Sonstiges:
  115.  |
  116.  +---------------------------------------------------------------------------*/
  117.  
  118. MRESULT EXPENTRY RequestProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  119. {
  120.    PFREQUESTDATA pRequestData = WinQueryWindowPtr(hwnd, QWL_USER);
  121.    HWND hwndList;
  122.    AREADEFLIST *pTemp;
  123.    BOOL bAreaSelected = FALSE;
  124.    SWP swp;
  125.    extern REQUESTOPT requestoptions;
  126.    PRAMLIST pRAMList;
  127.    ULONG ulStyle;
  128.  
  129.    switch(msg)
  130.    {
  131.       case WM_INITDLG:
  132.          pRequestData = calloc(1, sizeof(FREQUESTDATA));
  133.          pRequestData->pRequestPar = (PREQUESTPAR) mp2;
  134.  
  135.          /* Adresse */
  136.          WinSubclassWindow(WinWindowFromID(hwnd, IDD_REQUESTER+7), FidoEntryProc);
  137.          WinSendDlgItemMsg(hwnd, IDD_REQUESTER+7, EM_SETTEXTLIMIT,
  138.                            MPFROMLONG(LEN_5DADDRESS), NULL);
  139.          WinSetDlgItemText(hwnd, IDD_REQUESTER+7, pRequestData->pRequestPar->pchReqAddr);
  140.  
  141.          /* Areas in Drop-Down-Liste */
  142.          pTemp=pRequestData->pRequestPar->arealist->pFirstArea;
  143.          hwndList=WinWindowFromID(hwnd, IDD_REQUESTER+9);
  144.          WinEnableWindowUpdate(hwndList, FALSE);
  145.          while(pTemp)
  146.          {
  147.             if (pTemp->areadata.areatype == AREATYPE_NET)
  148.             {
  149.                SHORT sItem;
  150.  
  151.                sItem=(SHORT)SendMsg(hwndList, LM_INSERTITEM,
  152.                                        MPFROMSHORT(LIT_END),
  153.                                        pTemp->areadata.areatag);
  154.                if (*(pRequestData->pRequestPar->pchDestArea) &&
  155.                    !stricmp(pRequestData->pRequestPar->pchDestArea, pTemp->areadata.areatag))
  156.                {
  157.                   SendMsg(hwndList, LM_SELECTITEM,
  158.                              MPFROMSHORT(sItem), MPFROMLONG(TRUE));
  159.                   bAreaSelected=TRUE;
  160.                }
  161.             }
  162.  
  163.             pTemp=pTemp->next;
  164.          }
  165.          if (!bAreaSelected)
  166.          {
  167.             SHORT sItem=0;
  168.  
  169.             sItem=(SHORT)SendMsg(hwndList, LM_QUERYTOPINDEX, NULL, NULL);
  170.             SendMsg(hwndList, LM_SELECTITEM,
  171.                        MPFROMSHORT(sItem), MPFROMLONG(TRUE));
  172.          }
  173.          WinEnableWindowUpdate(hwndList, TRUE);
  174.  
  175.          /* Direct-Button bedienen */
  176.          WinCheckButton(hwnd, IDD_REQUESTER+11, pRequestData->pRequestPar->bDirect);
  177.          if (pRequestData->pRequestPar->bDirect)
  178.             WinEnableControl(hwnd, IDD_REQUESTER+9, FALSE);
  179.          else
  180.             WinEnableControl(hwnd, IDD_REQUESTER+9, TRUE);
  181.  
  182.          /* File-Listen */
  183.          RefreshFileList(hwnd, requestoptions.pFirstList);
  184.  
  185.          pRAMList = MessageToFileList(pRequestData->pRequestPar->pchFiles);
  186.  
  187.          FillFilesWindow(hwnd, pRAMList);
  188.          FreeFileList(pRAMList);
  189.  
  190.          /* Min. Fenstergroesse */
  191.          WinQueryWindowPos(WinWindowFromID(hwnd, IDD_REQUESTER+18), &swp);
  192.          pRequestData->MinSize.cx = swp.x + swp.cx + 10;
  193.          WinQueryWindowPos(WinWindowFromID(hwnd, IDD_REQUESTER+12), &swp);
  194.          pRequestData->MinSize.cy = swp.y + swp.cy + 25;
  195.  
  196.          /* Font, Farben */
  197.          hwndList = WinWindowFromID(hwnd, IDD_REQUESTER+13);
  198.          SetForeground(hwndList, &requestoptions.lListFore);
  199.          SetBackground(hwndList, &requestoptions.lListBack);
  200.          SetFont(hwndList, requestoptions.pchListFont);
  201.  
  202.          ulStyle = WinQueryWindowULong(hwndList, QWL_STYLE);
  203.          WinSetWindowULong(hwndList, QWL_STYLE, ulStyle | WS_TABSTOP);
  204.  
  205.          RestoreWinPos(hwnd, &requestoptions.ReqPos, TRUE, TRUE);
  206.          WinSetWindowPtr(hwnd, QWL_USER, pRequestData);
  207.          break;
  208.  
  209.       case WM_DESTROY:
  210.          {
  211.             LONG lTemp=0;
  212.             char pchTemp[FACESIZE+5]="";
  213.  
  214.             hwndList = WinWindowFromID(hwnd, IDD_REQUESTER+13);
  215.  
  216.             QueryForeground(hwndList, &lTemp);
  217.             if (requestoptions.lListFore != lTemp)
  218.             {
  219.                requestoptions.lListFore = lTemp;
  220.                requestoptions.bDirty = TRUE;
  221.             }
  222.             QueryBackground(hwndList, &lTemp);
  223.             if (requestoptions.lListBack != lTemp)
  224.             {
  225.                requestoptions.lListBack = lTemp;
  226.                requestoptions.bDirty = TRUE;
  227.             }
  228.             QueryFont(hwndList, pchTemp);
  229.             if (strcmp(requestoptions.pchListFont, pchTemp))
  230.             {
  231.                strcpy(requestoptions.pchListFont, pchTemp);
  232.                requestoptions.bDirty = TRUE;
  233.             }
  234.          }
  235.  
  236.          RemovePasswords(hwnd);
  237.          free(pRequestData);
  238.          break;
  239.  
  240.       case WM_ACTIVATE:
  241.          if (mp1)
  242.             WinAssociateHelpInstance(hwndhelp, hwnd);
  243.          else
  244.             WinAssociateHelpInstance(hwndhelp, NULLHANDLE);
  245.          break;
  246.  
  247.       case WM_COMMAND:
  248.          switch(SHORT1FROMMP(mp1))
  249.          {
  250.             case DID_OK:
  251.                CreateRequest(hwnd, pRequestData->pRequestPar);
  252.                break;
  253.  
  254.             case DID_CANCEL:
  255.                if (pRequestData->tidRead)
  256.                {
  257.                   /* Lese-Thread stoppen, dieser postet dann REQM_LISTREAD */
  258.  
  259.                   pRequestData->ListRead.bStop = TRUE;
  260.                   return (MRESULT) FALSE;
  261.                }
  262.                WinPostMsg(client, REQM_CLOSE, pRequestData->pRequestPar, MPFROMLONG(DID_CANCEL));
  263.                break;
  264.  
  265.             /* Attribute */
  266.             case IDD_REQUESTER+10:
  267.                {
  268.                   ATTRIBPAR AttribPar;
  269.  
  270.                   AttribPar.cb = sizeof(AttribPar);
  271.                   AttribPar.ulAttrib = pRequestData->pRequestPar->ulAttrib;
  272.                   if (WinQueryButtonCheckstate(hwnd, IDD_REQUESTER+11))
  273.                      AttribPar.ulAttribMask = ATTRIB_IMMEDIATE|ATTRIB_CRASH|ATTRIB_DIRECT|ATTRIB_HOLD;
  274.                   else
  275.                      AttribPar.ulAttribMask = 0xffffffff;
  276.                   AttribPar.bKeepRead = FALSE;
  277.  
  278.                   if (WinDlgBox(HWND_DESKTOP, hwnd, AttribProc, hmodLang,
  279.                                 IDD_ATTRIB, &AttribPar) == DID_OK)
  280.                      pRequestData->pRequestPar->ulAttrib = AttribPar.ulAttrib;
  281.  
  282.                }
  283.                return (MRESULT) FALSE;
  284.  
  285.             case IDD_REQUESTER+4: /* Liste hinzufuegen */
  286.                {
  287.                   LISTADDPAR ListAddPar;
  288.  
  289.                   memset(&ListAddPar, 0, sizeof(ListAddPar));
  290.                   ListAddPar.cb = sizeof(ListAddPar);
  291.  
  292.                   if (WinDlgBox(HWND_DESKTOP, hwnd, ListAddProc, hmodLang,
  293.                                 IDD_REQ_ADDLIST, &ListAddPar) == DID_OK)
  294.                   {
  295.                      AddNewFileList(&requestoptions.pFirstList, &ListAddPar.FileList,
  296.                                     &requestoptions.bListDirty);
  297.  
  298.                      RefreshFileList(hwnd, requestoptions.pFirstList);
  299.                   }
  300.                }
  301.                return (MRESULT) FALSE;
  302.  
  303.             case IDD_REQUESTER+5: /* Liste loeschen */
  304.                {
  305.                   PFILELIST pDelList = QueryFileList(hwnd);
  306.                   extern GENERALOPT generaloptions;
  307.  
  308.                   /* Sicherheitsabfrage */
  309.                   if (generaloptions.safety & SAFETY_CHANGESETUP)
  310.                      if (MessageBox(hwnd, IDST_MSG_REQ_DELLIST, IDST_TITLE_REQ_DELLIST,
  311.                                     IDD_REQ_DELLIST, MB_YESNO | MB_QUERY) != MBID_YES)
  312.                         return (MRESULT) FALSE;
  313.  
  314.                   if (pDelList)
  315.                   {
  316.                      DeleteFileList(&requestoptions.pFirstList, pDelList,
  317.                                     &requestoptions.bListDirty);
  318.                      RefreshFileList(hwnd, requestoptions.pFirstList);
  319.                   }
  320.                   else
  321.                      WinAlarm(HWND_DESKTOP, WA_NOTE);
  322.                }
  323.                return (MRESULT) FALSE;
  324.  
  325.             case IDD_REQUESTER+14: /* File hinzufuegen */
  326.                AddFile(hwnd);
  327.                return (MRESULT) FALSE;
  328.  
  329.             case IDD_REQUESTER+15: /* Suchen */
  330.                SearchInFiles(hwnd, FALSE);
  331.                return (MRESULT) FALSE;
  332.  
  333.             case IDD_REQUESTER+19: /* naechstes Suchen */
  334.                SearchInFiles(hwnd, TRUE);
  335.                return (MRESULT) FALSE;
  336.  
  337.             case IDD_REQUESTER+16: /* Passwort */
  338.                SetPassword(hwnd);
  339.                return (MRESULT) FALSE;
  340.  
  341.             case IDD_REQUESTER+17: /* Alle */
  342.                WinSendDlgItemMsg(hwnd, IDD_REQUESTER+13, LM_SELECTITEM,
  343.                                  MPFROMLONG(LIT_ALL), NULL);
  344.                return (MRESULT) FALSE;
  345.  
  346.             case IDD_REQUESTER+18: /* Keines */
  347.                WinSendDlgItemMsg(hwnd, IDD_REQUESTER+13, LM_SELECTITEM,
  348.                                  MPFROMLONG(LIT_NONE), NULL);
  349.                return (MRESULT) FALSE;
  350.  
  351.             case IDD_REQUESTER+20: /* Lookup */
  352.                LookupOtherLines(hwnd);
  353.                return (MRESULT) FALSE;
  354.  
  355.             default:
  356.                return (MRESULT) FALSE;
  357.          }
  358.          break;
  359.  
  360.       case WM_CONTROL:
  361.          switch(SHORT1FROMMP(mp1))
  362.          {
  363.             case IDD_REQUESTER+11: /* Checkbox */
  364.                if (pRequestData->pRequestPar->bDirect = WinQueryButtonCheckstate(hwnd, IDD_REQUESTER+11))
  365.                   WinEnableControl(hwnd, IDD_REQUESTER+9, FALSE);
  366.                else
  367.                   WinEnableControl(hwnd, IDD_REQUESTER+9, TRUE);
  368.                break;
  369.  
  370.             case IDD_REQUESTER+3: /* File-Listen */
  371.                switch(SHORT2FROMMP(mp1))
  372.                {
  373.                   case LN_ENTER:
  374.                      {
  375.                         PFILELIST pSelList = QueryFileList(hwnd);
  376.  
  377.                         /* Alten Inhalt löschen */
  378.                         FillFilesWindow(hwnd, NULL);
  379.  
  380.                         pRequestData->pCurrentList = pSelList;
  381.  
  382.                         if (pSelList)
  383.                         {
  384.                            /* echte Liste */
  385.                            WinSetDlgItemText(hwnd, IDD_REQUESTER+7, pSelList->pchAddress);
  386.  
  387.                            /* Thread-Parameter */
  388.                            memset(&pRequestData->ListRead, 0, sizeof(pRequestData->ListRead));
  389.  
  390.                            pRequestData->ListRead.pList = pSelList;
  391.                            pRequestData->ListRead.hwndNotify = hwnd;
  392.  
  393.                            /* Thread starten */
  394.                            ActivateControls(hwnd, FALSE);
  395.                            pRequestData->tidRead = _beginthread(ListReadThread, NULL, 16384, &pRequestData->ListRead);
  396.  
  397.                            if (pRequestData->tidRead < 0)
  398.                            {
  399.                               pRequestData->tidRead=0;
  400.                               ActivateControls(hwnd, TRUE);
  401.                               WinAlarm(HWND_DESKTOP, WA_ERROR);
  402.                            }
  403.                         }
  404.                         else
  405.                         {
  406.                            /* Pseudo-Liste */
  407.                            pRAMList = MessageToFileList(pRequestData->pRequestPar->pchFiles);
  408.                            FillFilesWindow(hwnd, pRAMList);
  409.                            FreeFileList(pRAMList);
  410.                            WinSetDlgItemText(hwnd, IDD_REQUESTER+7,
  411.                                              pRequestData->pRequestPar->pchReqAddr);
  412.                         }
  413.                      }
  414.                      break;
  415.  
  416.                   default:
  417.                      break;
  418.                }
  419.                break;
  420.  
  421.             default:
  422.                break;
  423.          }
  424.          break;
  425.  
  426.       case WM_ADJUSTFRAMEPOS:
  427.          if (((PSWP)mp1)->fl & (SWP_SIZE|SWP_MAXIMIZE|SWP_RESTORE))
  428.          {
  429.             RECTL rectl;
  430.             LONG lTemp;
  431.  
  432.             rectl.xLeft=0;
  433.             rectl.xRight=((PSWP)mp1)->cx;
  434.             rectl.yBottom=0;
  435.             rectl.yTop=((PSWP)mp1)->cy;
  436.  
  437.             CalcClientRect(anchor, hwnd, &rectl);
  438.  
  439.             /* File-Titel */
  440.             WinQueryWindowPos(WinWindowFromID(hwnd, IDD_REQUESTER+12), &swp);
  441.             WinSetWindowPos(WinWindowFromID(hwnd, IDD_REQUESTER+12),
  442.                             NULLHANDLE,
  443.                             swp.x, rectl.yTop - swp.cy,
  444.                             0, 0,
  445.                             SWP_MOVE);
  446.             lTemp = swp.cy;
  447.  
  448.             /* File-Liste */
  449.             WinQueryWindowPos(WinWindowFromID(hwnd, IDD_REQUESTER+13), &swp);
  450.             WinSetWindowPos(WinWindowFromID(hwnd, IDD_REQUESTER+13),
  451.                             NULLHANDLE,
  452.                             0, 0,
  453.                             rectl.xRight - swp.x,
  454.                             rectl.yTop - swp.y - lTemp,
  455.                             SWP_SIZE);
  456.          }
  457.          break;
  458.  
  459.        case WM_WINDOWPOSCHANGED:
  460.          if (pRequestData)
  461.             SaveWinPos(hwnd, (PSWP) mp1, &requestoptions.ReqPos, &requestoptions.bDirty);
  462.          break;
  463.  
  464.       case WM_QUERYTRACKINFO:
  465.          if (pRequestData)
  466.          {
  467.             MRESULT resultbuf;
  468.  
  469.             /* Default-Werte aus Original-Prozedur holen */
  470.             resultbuf=WinDefDlgProc(hwnd, msg, mp1, mp2);
  471.  
  472.             /* Minimale Fenstergroesse einstellen */
  473.             ((PTRACKINFO)mp2)->ptlMinTrackSize.x=pRequestData->MinSize.cx;
  474.             ((PTRACKINFO)mp2)->ptlMinTrackSize.y=pRequestData->MinSize.cy;
  475.             return resultbuf;
  476.          }
  477.          else
  478.             break;
  479.  
  480.       case WM_CLOSE:
  481.          if (pRequestData->tidRead)
  482.          {
  483.             /* Lese-Thread stoppen, dieser postet dann REQM_LISTREAD */
  484.  
  485.             pRequestData->ListRead.bStop = TRUE;
  486.             return (MRESULT) FALSE;
  487.          }
  488.  
  489.          WinPostMsg(client, REQM_CLOSE, pRequestData->pRequestPar, MPFROMLONG(DID_CANCEL));
  490.          break;
  491.  
  492.       case REQM_LISTREAD:
  493.          pRequestData->tidRead=0;
  494.  
  495.          /* evtl. Fehlermeldung ausgeben */
  496.          switch(pRequestData->ListRead.ulRetCode)
  497.          {
  498.             case FILELIST_NOTF:
  499.                MessageBox(hwnd, IDST_MSG_REQ_NOTF, 0, IDD_REQ_ERROR, MB_OK);
  500.                break;
  501.  
  502.             case FILELIST_READERR:
  503.                MessageBox(hwnd, IDST_MSG_REQ_READERR, 0, IDD_REQ_ERROR, MB_OK);
  504.                break;
  505.  
  506.             case FILELIST_STOPPED:
  507.                /* Abgebrochen durch Close oder Cancel, Close nochmal posten */
  508.                WinPostMsg(hwnd, WM_CLOSE, NULL, NULL);
  509.                break;
  510.  
  511.             default:
  512.                break;
  513.          }
  514.          ActivateControls(hwnd, TRUE);
  515.  
  516.          /* gelesene Daten anzeigen */
  517.          FillFilesWindow(hwnd, pRequestData->ListRead.pReadList);
  518.          FreeFileList(pRequestData->ListRead.pReadList);
  519.          return (MRESULT) FALSE;
  520.  
  521.       default:
  522.          break;
  523.    }
  524.    return WinDefDlgProc(hwnd, msg, mp1, mp2);
  525. }
  526.  
  527. static void ActivateControls(HWND hwndDlg, BOOL bActivate)
  528. {
  529.    WinEnableControl(hwndDlg, IDD_REQUESTER+3, bActivate);
  530.    WinEnableControl(hwndDlg, IDD_REQUESTER+14, bActivate);
  531.    WinEnableControl(hwndDlg, IDD_REQUESTER+15, bActivate);
  532.    WinEnableControl(hwndDlg, IDD_REQUESTER+16, bActivate);
  533.    WinEnableControl(hwndDlg, IDD_REQUESTER+17, bActivate);
  534.    WinEnableControl(hwndDlg, IDD_REQUESTER+18, bActivate);
  535.    WinEnableControl(hwndDlg, IDD_REQUESTER+19, bActivate);
  536.    WinEnableControl(hwndDlg, DID_OK, bActivate);
  537.  
  538.    return;
  539. }
  540.  
  541. static void CreateRequest(HWND hwnd, PREQUESTPAR pRequestPar)
  542. {
  543.    LONG sItem;
  544.    HWND hwndList = WinWindowFromID(hwnd, IDD_REQUESTER+13);
  545.    PREQUESTLIST pLast=NULL;
  546.  
  547.    sItem = LIT_FIRST;
  548.    while((sItem=(LONG)SendMsg(hwndList, LM_QUERYSELECTION,
  549.                               MPFROMLONG(sItem), NULL))!=LIT_NONE)
  550.    {
  551.       char pchTemp[50];
  552.       char *pchPassword;
  553.  
  554.       SendMsg(hwndList, LM_QUERYITEMTEXT, MPFROMLONG(sItem), MPFROMP(pchTemp));
  555.       if (IsFileName(pchTemp, FALSE))
  556.       {
  557.          if (pRequestPar->pReqList)
  558.          {
  559.             pLast->next = calloc(1, sizeof(REQUESTLIST));
  560.             pLast = pLast->next;
  561.          }
  562.          else
  563.             pLast = pRequestPar->pReqList = calloc(1, sizeof(REQUESTLIST));
  564.  
  565.          AddFileName(pLast->pchFileName, pchTemp);
  566.          pchPassword = (PCHAR) SendMsg(hwndList, LM_QUERYITEMHANDLE,
  567.                                                  MPFROMLONG(sItem), NULL);
  568.          if (pchPassword)
  569.             strncpy(pLast->pchPassword, pchPassword, LEN_PASSWORD);
  570.       }
  571.    }
  572.    WinQueryDlgItemText(hwnd, IDD_REQUESTER+7, LEN_5DADDRESS+1, pRequestPar->pchReqAddr);
  573.    sItem=(SHORT)WinSendDlgItemMsg(hwnd, IDD_REQUESTER+9, LM_QUERYSELECTION,
  574.                                   MPFROMSHORT(LIT_FIRST), NULL);
  575.    WinSendDlgItemMsg(hwnd, IDD_REQUESTER+9, LM_QUERYITEMTEXT,
  576.                      MPFROM2SHORT(sItem, LEN_AREATAG+1), pRequestPar->pchDestArea);
  577.    strcpy(pRequestPar->pchReqName, "Sysop");
  578.    SendMsg(client, REQM_REQUEST, pRequestPar, NULL);
  579.    WinPostMsg(client, REQM_CLOSE, pRequestPar, MPFROMLONG(DID_OK));
  580.  
  581.    return;
  582. }
  583.  
  584. static void RemovePasswords(HWND hwnd)
  585. {
  586.    HWND hwndList = WinWindowFromID(hwnd, IDD_REQUESTER+13);
  587.    LONG sItem, sItemCount;
  588.    PVOID pTemp;
  589.  
  590.    /* Passwoerter freigeben */
  591.    sItemCount = (LONG) SendMsg(hwndList, LM_QUERYITEMCOUNT, NULL, NULL);
  592.  
  593.    for (sItem =0; sItem < sItemCount; sItem++)
  594.    {
  595.       pTemp = SendMsg(hwndList, LM_QUERYITEMHANDLE, MPFROMLONG(sItem), NULL);
  596.       if (pTemp)
  597.          free(pTemp);
  598.    }
  599.  
  600.    return;
  601. }
  602.  
  603. static void RefreshFileList(HWND hwndDlg, PFILELIST pList)
  604. {
  605.    HWND hwndList = WinWindowFromID(hwndDlg, IDD_REQUESTER+3);
  606.    SHORT sItem;
  607.    PFILELIST pTemp = pList;
  608.  
  609.    WinSendMsg(hwndList, LM_DELETEALL, NULL, NULL);
  610.  
  611.    /* Dummy-Liste einfügen */
  612.    WinSendMsg(hwndList, LM_INSERTITEM, MPFROMSHORT(LIT_END),
  613.               /* @@ */
  614.               "Message");
  615.  
  616.    /* alle Listen-Elemente */
  617.    while (pTemp)
  618.    {
  619.       sItem = (SHORT) WinSendMsg(hwndList, LM_INSERTITEM, MPFROMSHORT(LIT_END),
  620.                                  pTemp->pchDesc);
  621.  
  622.       if (sItem >= 0)
  623.          WinSendMsg(hwndList, LM_SETITEMHANDLE, MPFROMSHORT(sItem), pTemp);
  624.  
  625.       pTemp = pTemp->next;
  626.    }
  627.  
  628.    /* Loesch-Button */
  629.    if (pList)
  630.       WinEnableControl(hwndDlg, IDD_REQUESTER+5, TRUE);
  631.    else
  632.       WinEnableControl(hwndDlg, IDD_REQUESTER+5, FALSE);
  633.  
  634.    return;
  635. }
  636.  
  637. static void FillFilesWindow(HWND hwndDlg, PRAMLIST pRAMList)
  638. {
  639.    HWND hwndList = WinWindowFromID(hwndDlg, IDD_REQUESTER+13);
  640.    LBOXINFO InsertInfo = {LIT_END, 0, 0, 0};
  641.    PRAMLIST pTemp = pRAMList;
  642.    PCHAR *pInsertArray;
  643.    ULONG ulNum;
  644.  
  645.    WinEnableWindowUpdate(hwndList, FALSE);
  646.    SendMsg(hwndList, LM_DELETEALL, NULL, NULL);
  647.  
  648.    ulNum = WinQueryWindowULong(hwndList, QWL_STYLE);
  649.    WinSetWindowULong(hwndList, QWL_STYLE, ulNum | WS_TABSTOP);
  650.  
  651.    while (pTemp)
  652.    {
  653.       InsertInfo.ulItemCount++;
  654.       pTemp = pTemp->next;
  655.    }
  656.    pInsertArray = malloc(InsertInfo.ulItemCount * sizeof(PCHAR));
  657.    for (pTemp = pRAMList, ulNum = 0; pTemp; pTemp = pTemp->next, ulNum++)
  658.       pInsertArray[ulNum] = pTemp->pchLine;
  659.  
  660.    SendMsg(hwndList, LM_INSERTMULTITEMS, &InsertInfo, pInsertArray);
  661.  
  662.    free(pInsertArray);
  663.  
  664.    WinEnableWindowUpdate(hwndList, TRUE);
  665.  
  666.    return;
  667. }
  668.  
  669. static MRESULT EXPENTRY ListAddProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  670. {
  671.    PLISTADDPAR pListAddPar = WinQueryWindowPtr(hwnd, QWL_USER);
  672.    extern REQUESTOPT requestoptions;
  673.  
  674.    switch(msg)
  675.    {
  676.       case WM_INITDLG:
  677.          pListAddPar = (PLISTADDPAR) mp2;
  678.          WinSubclassWindow(WinWindowFromID(hwnd, IDD_REQ_ADDLIST+5), FidoEntryProc);
  679.  
  680.          WinSendDlgItemMsg(hwnd, IDD_REQ_ADDLIST+2, EM_SETTEXTLIMIT,
  681.                            MPFROMSHORT(LEN_PATHNAME), NULL);
  682.          WinSendDlgItemMsg(hwnd, IDD_REQ_ADDLIST+5, EM_SETTEXTLIMIT,
  683.                            MPFROMSHORT(LEN_5DADDRESS), NULL);
  684.          WinSendDlgItemMsg(hwnd, IDD_REQ_ADDLIST+7, EM_SETTEXTLIMIT,
  685.                            MPFROMSHORT(LEN_LISTDESC), NULL);
  686.  
  687.          RestoreWinPos(hwnd, &requestoptions.ListAddPos, FALSE, TRUE);
  688.          WinSetWindowPtr(hwnd, QWL_USER, pListAddPar);
  689.          break;
  690.  
  691.        case WM_WINDOWPOSCHANGED:
  692.          if (pListAddPar)
  693.             SaveWinPos(hwnd, (PSWP) mp1, &requestoptions.ListAddPos, &requestoptions.bDirty);
  694.          break;
  695.  
  696.       case WM_COMMAND:
  697.          switch(SHORT1FROMMP(mp1))
  698.          {
  699.             case DID_OK:
  700.                WinQueryDlgItemText(hwnd, IDD_REQ_ADDLIST+2, sizeof(pListAddPar->FileList.pchFileName),
  701.                                    pListAddPar->FileList.pchFileName);
  702.                WinQueryDlgItemText(hwnd, IDD_REQ_ADDLIST+5, sizeof(pListAddPar->FileList.pchAddress),
  703.                                    pListAddPar->FileList.pchAddress);
  704.                WinQueryDlgItemText(hwnd, IDD_REQ_ADDLIST+7, sizeof(pListAddPar->FileList.pchDesc),
  705.                                    pListAddPar->FileList.pchDesc);
  706.                break;
  707.  
  708.             case DID_CANCEL:
  709.                break;
  710.  
  711.             case IDD_REQ_ADDLIST+3:   /* Suchen */
  712.                {
  713.                   char pchPath[LEN_PATHNAME+1]="";
  714.  
  715.                   WinQueryDlgItemText(hwnd, IDD_REQ_ADDLIST+2, sizeof(pchPath), pchPath);
  716.                   if (GetPathname(hwnd, pchPath) == DID_OK)
  717.                   {
  718.                      WinSetDlgItemText(hwnd, IDD_REQ_ADDLIST+2, pchPath);
  719.  
  720.                      if (WinQueryDlgItemTextLength(hwnd, IDD_REQ_ADDLIST+2) &&
  721.                          WinQueryDlgItemTextLength(hwnd, IDD_REQ_ADDLIST+5) &&
  722.                          WinQueryDlgItemTextLength(hwnd, IDD_REQ_ADDLIST+7))
  723.                         WinEnableControl(hwnd, DID_OK, TRUE);
  724.                      else
  725.                         WinEnableControl(hwnd, DID_OK, FALSE);
  726.                   }
  727.                }
  728.                return (MRESULT) FALSE;
  729.  
  730.             default:
  731.                break;
  732.          }
  733.          break;
  734.  
  735.       case WM_ACTIVATE:
  736.          if (mp1)
  737.             WinAssociateHelpInstance(hwndhelp, hwnd);
  738.          else
  739.             WinAssociateHelpInstance(hwndhelp, NULLHANDLE);
  740.          break;
  741.  
  742.       case WM_CHAR:
  743.          if (WinQueryDlgItemTextLength(hwnd, IDD_REQ_ADDLIST+2) &&
  744.              WinQueryDlgItemTextLength(hwnd, IDD_REQ_ADDLIST+5) &&
  745.              WinQueryDlgItemTextLength(hwnd, IDD_REQ_ADDLIST+7))
  746.             WinEnableControl(hwnd, DID_OK, TRUE);
  747.          else
  748.             WinEnableControl(hwnd, DID_OK, FALSE);
  749.          break;
  750.  
  751.       default:
  752.          break;
  753.    }
  754.    return WinDefDlgProc(hwnd, msg, mp1, mp2);
  755. }
  756.  
  757. static MRESULT EXPENTRY FileAddProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  758. {
  759.    PFILEADDPAR pFileAddPar = WinQueryWindowPtr(hwnd, QWL_USER);
  760.    extern REQUESTOPT requestoptions;
  761.  
  762.    switch(msg)
  763.    {
  764.       case WM_INITDLG:
  765.          pFileAddPar = (PFILEADDPAR) mp2;
  766.  
  767.          WinSendDlgItemMsg(hwnd, IDD_REQ_ADDFILE+2, EM_SETTEXTLIMIT,
  768.                            MPFROMSHORT(LEN_REQFILE), NULL);
  769.          WinSendDlgItemMsg(hwnd, IDD_REQ_ADDFILE+4, EM_SETTEXTLIMIT,
  770.                            MPFROMSHORT(LEN_PASSWORD), NULL);
  771.  
  772.          RestoreWinPos(hwnd, &requestoptions.FileAddPos, FALSE, TRUE);
  773.          WinSetWindowPtr(hwnd, QWL_USER, pFileAddPar);
  774.          break;
  775.  
  776.        case WM_WINDOWPOSCHANGED:
  777.          if (pFileAddPar)
  778.             SaveWinPos(hwnd, (PSWP) mp1, &requestoptions.FileAddPos, &requestoptions.bDirty);
  779.          break;
  780.  
  781.       case WM_COMMAND:
  782.          switch(SHORT1FROMMP(mp1))
  783.          {
  784.             case DID_OK:
  785.                WinQueryDlgItemText(hwnd, IDD_REQ_ADDFILE+2, sizeof(pFileAddPar->pchFileName),
  786.                                    pFileAddPar->pchFileName);
  787.                WinQueryDlgItemText(hwnd, IDD_REQ_ADDFILE+4, sizeof(pFileAddPar->pchPassword),
  788.                                    pFileAddPar->pchPassword);
  789.                break;
  790.  
  791.             case DID_CANCEL:
  792.                break;
  793.  
  794.             default:
  795.                break;
  796.          }
  797.          break;
  798.  
  799.       case WM_ACTIVATE:
  800.          if (mp1)
  801.             WinAssociateHelpInstance(hwndhelp, hwnd);
  802.          else
  803.             WinAssociateHelpInstance(hwndhelp, NULLHANDLE);
  804.          break;
  805.  
  806.       case WM_CHAR:
  807.          if (WinQueryDlgItemTextLength(hwnd, IDD_REQ_ADDFILE+2))
  808.             WinEnableControl(hwnd, DID_OK, TRUE);
  809.          else
  810.             WinEnableControl(hwnd, DID_OK, FALSE);
  811.          break;
  812.  
  813.       default:
  814.          break;
  815.    }
  816.    return WinDefDlgProc(hwnd, msg, mp1, mp2);
  817. }
  818.  
  819. static void AddFile(HWND hwndDlg)
  820. {
  821.    FILEADDPAR FileAddPar;
  822.  
  823.    memset(&FileAddPar, 0, sizeof(FileAddPar));
  824.    FileAddPar.cb = sizeof(FileAddPar);
  825.  
  826.    if (WinDlgBox(HWND_DESKTOP, hwndDlg, FileAddProc, hmodLang,
  827.                  IDD_REQ_ADDFILE, &FileAddPar) == DID_OK)
  828.    {
  829.       LONG sItem;
  830.  
  831.       sItem = (LONG) WinSendDlgItemMsg(hwndDlg, IDD_REQUESTER+13, LM_INSERTITEM,
  832.                                         MPFROMLONG(LIT_END), FileAddPar.pchFileName);
  833.       if (sItem >= 0)
  834.       {
  835.          if (FileAddPar.pchPassword[0])
  836.             WinSendDlgItemMsg(hwndDlg, IDD_REQUESTER+13, LM_SETITEMHANDLE,
  837.                               MPFROMLONG(sItem), strdup(FileAddPar.pchPassword));
  838.          WinSendDlgItemMsg(hwndDlg, IDD_REQUESTER+13, LM_SELECTITEM,
  839.                               MPFROMLONG(sItem), MPFROMLONG(TRUE));
  840.       }
  841.    }
  842.  
  843.    return;
  844. }
  845.  
  846. static MRESULT EXPENTRY PasswordProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  847. {
  848.    PPASSWORDPAR pPasswordPar = WinQueryWindowPtr(hwnd, QWL_USER);
  849.    extern REQUESTOPT requestoptions;
  850.  
  851.    switch(msg)
  852.    {
  853.       case WM_INITDLG:
  854.          pPasswordPar = (PPASSWORDPAR) mp2;
  855.  
  856.          WinSendDlgItemMsg(hwnd, IDD_REQ_SETPASS+2, EM_SETTEXTLIMIT,
  857.                            MPFROMSHORT(LEN_PASSWORD), NULL);
  858.          WinSetDlgItemText(hwnd, IDD_REQ_SETPASS+2, pPasswordPar->pchPassword);
  859.  
  860.  
  861.          RestoreWinPos(hwnd, &requestoptions.PasswdPos, FALSE, TRUE);
  862.          WinSetWindowPtr(hwnd, QWL_USER, pPasswordPar);
  863.          break;
  864.  
  865.        case WM_WINDOWPOSCHANGED:
  866.          if (pPasswordPar)
  867.             SaveWinPos(hwnd, (PSWP) mp1, &requestoptions.PasswdPos, &requestoptions.bDirty);
  868.          break;
  869.  
  870.       case WM_COMMAND:
  871.          switch(SHORT1FROMMP(mp1))
  872.          {
  873.             case DID_OK:
  874.                WinQueryDlgItemText(hwnd, IDD_REQ_SETPASS+2, sizeof(pPasswordPar->pchPassword),
  875.                                    pPasswordPar->pchPassword);
  876.                break;
  877.  
  878.             case DID_CANCEL:
  879.                break;
  880.  
  881.             default:
  882.                break;
  883.          }
  884.          break;
  885.  
  886.       case WM_ACTIVATE:
  887.          if (mp1)
  888.             WinAssociateHelpInstance(hwndhelp, hwnd);
  889.          else
  890.             WinAssociateHelpInstance(hwndhelp, NULLHANDLE);
  891.          break;
  892.  
  893.       default:
  894.          break;
  895.    }
  896.    return WinDefDlgProc(hwnd, msg, mp1, mp2);
  897. }
  898.  
  899. static PFILELIST QueryFileList(HWND hwndDlg)
  900. {
  901.    HWND hwndList = WinWindowFromID(hwndDlg, IDD_REQUESTER+3);
  902.    SHORT sItem;
  903.  
  904.    sItem = (SHORT) SendMsg(hwndList, LM_QUERYSELECTION, MPFROMSHORT(LIT_CURSOR),
  905.                            NULL);
  906.  
  907.    if (sItem >= 0)
  908.       return (PFILELIST) SendMsg(hwndList, LM_QUERYITEMHANDLE, MPFROMSHORT(sItem),
  909.                                  NULL);
  910.    else
  911.       return NULL;
  912. }
  913.  
  914. static void AddFileName(char *pchDest, char *pchName)
  915. {
  916.    pchDest = strchr(pchDest, '\0');
  917.    while (*pchName == ' ')
  918.       pchName++;
  919.  
  920.    while (*pchName && *pchName != ' ')
  921.       *pchDest++ = *pchName++;
  922.  
  923.    *pchDest=0;
  924.  
  925.    return;
  926.  
  927. }
  928.  
  929. static void SetPassword(HWND hwndDlg)
  930. {
  931.    PASSWORDPAR PasswordPar;
  932.    HWND hwndList = WinWindowFromID(hwndDlg, IDD_REQUESTER+13);
  933.    LONG sItem;
  934.    PCHAR pchPassword;
  935.  
  936.    memset(&PasswordPar, 0, sizeof(PasswordPar));
  937.    PasswordPar.cb = sizeof(PasswordPar);
  938.  
  939.    sItem = (LONG) SendMsg(hwndList, LM_QUERYSELECTION, MPFROMLONG(LIT_CURSOR), NULL);
  940.  
  941.    if (sItem >= 0)
  942.    {
  943.       pchPassword = (PCHAR) SendMsg(hwndList, LM_QUERYITEMHANDLE,
  944.                                     MPFROMLONG(sItem), NULL);
  945.       if (pchPassword)
  946.          strncpy(PasswordPar.pchPassword, pchPassword, LEN_PASSWORD);
  947.  
  948.       if (WinDlgBox(HWND_DESKTOP, hwndDlg, PasswordProc, hmodLang,
  949.                     IDD_REQ_SETPASS, &PasswordPar) == DID_OK)
  950.       {
  951.          if (pchPassword)
  952.             free(pchPassword);
  953.          if (PasswordPar.pchPassword)
  954.             pchPassword = strdup(PasswordPar.pchPassword);
  955.          else
  956.             pchPassword = NULL;
  957.          SendMsg(hwndList, LM_SETITEMHANDLE, MPFROMLONG(sItem),
  958.                  pchPassword);
  959.       }
  960.    }
  961.  
  962.    return;
  963. }
  964.  
  965. static void SearchInFiles(HWND hwndDlg, BOOL bSearchNext)
  966. {
  967.    SEARCHPAR SearchPar;
  968.    LONG sTop;
  969.    HWND hwndList = WinWindowFromID(hwndDlg, IDD_REQUESTER+13);
  970.    extern REQUESTOPT requestoptions;
  971.  
  972.    /* Top-Message abfragen */
  973.    sTop = (LONG) SendMsg(hwndList, LM_QUERYTOPINDEX, NULL, NULL);
  974.  
  975.    if (sTop >= 0)
  976.    {
  977.       /* Begriff holen */
  978.       memset(&SearchPar, 0, sizeof(SearchPar));
  979.       SearchPar.cb = sizeof(SearchPar);
  980.       SearchPar.DlgPos = requestoptions.SearchPos;
  981.       SearchPar.ulSearchFlags = requestoptions.ulSearchFlags;
  982.       strcpy(SearchPar.pchSearchText, requestoptions.pchLastSearch);
  983.  
  984.       if ((bSearchNext && SearchPar.pchSearchText[0]) ||
  985.           (WinDlgBox(HWND_DESKTOP, hwndDlg, SearchProc, hmodLang,
  986.                      IDD_SEARCH, &SearchPar) == DID_OK))
  987.       {
  988.          LONG sMatch;
  989.          LBSEARCH LBSearch = { LSS_SUBSTRING, 0};
  990.  
  991.          LBSearch.lItemStart = sTop;
  992.  
  993.          if (SearchPar.ulSearchFlags & SEARCHFLAG_CASESENSITIVE)
  994.             LBSearch.usCmd |= LSS_CASESENSITIVE;
  995.  
  996.          /* Suchen */
  997.          sMatch = (LONG) SendMsg(hwndList, LM_SEARCHSTRING,
  998.                                  &LBSearch,
  999.                                  SearchPar.pchSearchText);
  1000.  
  1001.          /* gefundene Stelle anzeigen */
  1002.          if (sMatch >= 0)
  1003.             SendMsg(hwndList, LM_SETTOPINDEX, MPFROMLONG(sMatch), NULL);
  1004.          else
  1005.             WinAlarm(HWND_DESKTOP, WA_ERROR);
  1006.  
  1007.          /* Daten zurückholen */
  1008.          requestoptions.SearchPos = SearchPar.DlgPos;
  1009.          strcpy(requestoptions.pchLastSearch, SearchPar.pchSearchText);
  1010.          requestoptions.ulSearchFlags = SearchPar.ulSearchFlags;
  1011.          requestoptions.bDirty = TRUE;
  1012.       }
  1013.    }
  1014.  
  1015.    return;
  1016. }
  1017.  
  1018. void FreeRequestList(PREQUESTLIST pList)
  1019. {
  1020.    PREQUESTLIST pNext;
  1021.  
  1022.    while (pList)
  1023.    {
  1024.       pNext = pList->next;
  1025.       free(pList);
  1026.       pList = pNext;
  1027.    }
  1028.    return;
  1029. }
  1030.  
  1031. static int LookupOtherLines(HWND hwnd)
  1032. {
  1033.    char pchAddress[LEN_5DADDRESS+1];
  1034.    char pchSysop[LEN_USERNAME+1];
  1035.  
  1036.  
  1037.    WinQueryDlgItemText(hwnd, IDD_REQUESTER+7, sizeof(pchAddress), pchAddress);
  1038.  
  1039.    if (pchAddress[0])
  1040.    {
  1041.       if (PerformNodeLookup(pchAddress, hwnd, pchSysop))
  1042.       {
  1043.          if (PerformNameLookup(pchSysop, hwnd, LOOKUP_FORCESELECT, pchSysop, pchAddress))
  1044.          {
  1045.             WinSetDlgItemText(hwnd, IDD_REQUESTER+7, pchAddress);
  1046.             return 0;
  1047.          }
  1048.          else
  1049.             return 1;
  1050.       }
  1051.       else
  1052.          return 1;
  1053.    }
  1054.    else
  1055.       return 1;
  1056. }
  1057.  
  1058. /*-------------------------------- Modulende --------------------------------*/
  1059.  
  1060.