home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / lora299s.zip / MSGCOMBO.CPP < prev    next >
C/C++ Source or Header  |  1996-05-29  |  9KB  |  352 lines

  1.  
  2. // ----------------------------------------------------------------------
  3. // Lora BBS Professional Edition - Version 3.00.1
  4. // Copyright (c) 1996 by Marco Maccaferri. All rights reserved.
  5. //
  6. // History:
  7. //    04/22/95 - Initial coding.
  8. // ----------------------------------------------------------------------
  9.  
  10. #include "_ldefs.h"
  11. #include "msgbase.h"
  12.  
  13. typedef struct {
  14.    ULONG  Number;
  15.    ULONG  RealNumber;
  16.    USHORT Storage;
  17.    CHAR   Path[64];
  18. } COMBOINDEX;
  19.  
  20. COMBO::COMBO (void)
  21. {
  22.    Id = 0L;
  23.    TotalMsgs = 0L;
  24.    NextNumber = 0L;
  25.    Msg = NULL;
  26.    Index.Clear ();
  27. }
  28.  
  29. COMBO::~COMBO (void)
  30. {
  31.    Index.Clear ();
  32. }
  33.  
  34. USHORT COMBO::Add (VOID)
  35. {
  36.    return (FALSE);
  37. }
  38.  
  39. USHORT COMBO::Add (class TMsgBase *MsgBase)
  40. {
  41.    return (FALSE);
  42. }
  43.  
  44. USHORT COMBO::Add (class TCollection &MsgText)
  45. {
  46.    return (FALSE);
  47. }
  48.  
  49. USHORT COMBO::Add (PSZ pszPath, USHORT usStorage, ULONG ulNumber)
  50. {
  51.    USHORT RetVal;
  52.    COMBOINDEX msgIndex;
  53.  
  54.    memset (&msgIndex, 0, sizeof (msgIndex));
  55.    msgIndex.Number = NextNumber;
  56.    msgIndex.RealNumber = ulNumber;
  57.    msgIndex.Storage = usStorage;
  58.    strcpy (msgIndex.Path, pszPath);
  59.    if ((RetVal = Index.Add (&msgIndex, (USHORT)sizeof (COMBOINDEX))) == TRUE)
  60.       TotalMsgs++;
  61.  
  62.    return (RetVal);
  63. }
  64.  
  65. VOID COMBO::Close (VOID)
  66. {
  67. }
  68.  
  69. USHORT COMBO::Delete (ULONG ulMsg)
  70. {
  71.    USHORT RetVal = FALSE;
  72.    COMBOINDEX *msgIndex;
  73.  
  74.    if ((msgIndex = (COMBOINDEX *)Index.First ()) != NULL)
  75.       do {
  76.          if (msgIndex->Number == ulMsg) {
  77.             Index.Remove ();
  78.             TotalMsgs--;
  79.             RetVal = TRUE;
  80.          }
  81.       } while ((msgIndex = (COMBOINDEX *)Index.Next ()) != NULL);
  82.  
  83.    return (RetVal);
  84. }
  85.  
  86. USHORT COMBO::GetHWM (ULONG &ulMsg)
  87. {
  88.    ulMsg = 0L;
  89.  
  90.    return (FALSE);
  91. }
  92.  
  93. ULONG COMBO::Highest (VOID)
  94. {
  95.    ULONG RetVal = 0L;
  96.    COMBOINDEX *msgIndex;
  97.  
  98.    if ((msgIndex = (COMBOINDEX *)Index.Last ()) != NULL)
  99.       RetVal = msgIndex->Number;
  100.  
  101.    return (RetVal);
  102. }
  103.  
  104. USHORT COMBO::Lock (ULONG ulTimeout)
  105. {
  106.    ulTimeout = ulTimeout;
  107.    return (TRUE);
  108. }
  109.  
  110. ULONG COMBO::Lowest (VOID)
  111. {
  112.    ULONG RetVal = 0L;
  113.    COMBOINDEX *msgIndex;
  114.  
  115.    if ((msgIndex = (COMBOINDEX *)Index.First ()) != NULL)
  116.       RetVal = msgIndex->Number;
  117.  
  118.    return (RetVal);
  119. }
  120.  
  121. VOID COMBO::New (VOID)
  122. {
  123.    From[0] = To[0] = Subject[0] = '\0';
  124.    Crash = Direct = FileAttach = FileRequest = Hold = Immediate = FALSE;
  125.    Intransit = KillSent = Local = Private = ReceiptRequest = Received = FALSE;
  126.    Sent = 0;
  127.    memset (&Written, 0, sizeof (Written));
  128.    Written.Month = 1;
  129.    memset (&Arrived, 0, sizeof (Arrived));
  130.    Arrived.Month = 1;
  131.    Text.Clear ();
  132. }
  133.  
  134. USHORT COMBO::Next (ULONG &ulMsg)
  135. {
  136.    USHORT RetVal = FALSE;
  137.    COMBOINDEX *msgIndex;
  138.  
  139.    if ((msgIndex = (COMBOINDEX *)Index.Next ()) != NULL) {
  140.       ulMsg = msgIndex->Number;
  141.       RetVal = TRUE;
  142.    }
  143.  
  144.    return (RetVal);
  145. }
  146.  
  147. ULONG COMBO::Number (VOID)
  148. {
  149.    return (TotalMsgs);
  150. }
  151.  
  152. VOID COMBO::Pack (VOID)
  153. {
  154. }
  155.  
  156. USHORT COMBO::Previous (ULONG &ulMsg)
  157. {
  158.    USHORT RetVal = FALSE;
  159.    COMBOINDEX *msgIndex;
  160.  
  161.    if ((msgIndex = (COMBOINDEX *)Index.Previous ()) != NULL) {
  162.       ulMsg = msgIndex->Number;
  163.       RetVal = TRUE;
  164.    }
  165.  
  166.    return (RetVal);
  167. }
  168.  
  169. USHORT COMBO::ReadHeader (ULONG ulMsg)
  170. {
  171.    USHORT RetVal = FALSE;
  172.    COMBOINDEX *msgIndex;
  173.  
  174.    New ();
  175.  
  176.    if ((msgIndex = (COMBOINDEX *)Index.First ()) != NULL)
  177.       do {
  178.          if (msgIndex->Number == ulMsg) {
  179.             if (Msg != NULL && stricmp (LastPath, msgIndex->Path)) {
  180.                delete Msg;
  181.                Msg = NULL;
  182.             }
  183.             if (Msg == NULL) {
  184.                if (msgIndex->Storage == ST_JAM)
  185.                   Msg = new JAM (msgIndex->Path);
  186.                else if (msgIndex->Storage == ST_SQUISH)
  187.                   Msg = new SQUISH (msgIndex->Path);
  188.                else if (msgIndex->Storage == ST_FIDO)
  189.                   Msg = new FIDOSDM (msgIndex->Path);
  190.                else if (msgIndex->Storage == ST_ADEPT)
  191.                   Msg = new ADEPT (msgIndex->Path);
  192.             }
  193.             if (Msg != NULL) {
  194.                strcpy (LastPath, msgIndex->Path);
  195.                Current = msgIndex->Number;
  196.                if (Msg->ReadHeader (msgIndex->RealNumber) == TRUE) {
  197.                   New ();
  198.                   RetVal = TRUE;
  199.  
  200.                   strcpy (From, Msg->From);
  201.                   strcpy (To, Msg->To);
  202.                   strcpy (Subject, Msg->Subject);
  203.  
  204.                   strcpy (FromAddress, Msg->FromAddress);
  205.                   strcpy (ToAddress, Msg->ToAddress);
  206.  
  207.                   Written.Day = Msg->Written.Day;
  208.                   Written.Month = Msg->Written.Month;
  209.                   Written.Year = Msg->Written.Year;
  210.                   Written.Hour = Msg->Written.Hour;
  211.                   Written.Minute = Msg->Written.Minute;
  212.                   Written.Second = Msg->Written.Second;
  213.  
  214.                   Arrived.Day = Msg->Arrived.Day;
  215.                   Arrived.Month = Msg->Arrived.Month;
  216.                   Arrived.Year = Msg->Arrived.Year;
  217.                   Arrived.Hour = Msg->Arrived.Hour;
  218.                   Arrived.Minute = Msg->Arrived.Minute;
  219.                   Arrived.Second = Msg->Arrived.Second;
  220.  
  221.                   Crash = Msg->Crash;
  222.                   Direct = Msg->Direct;
  223.                   FileAttach = Msg->FileAttach;
  224.                   FileRequest = Msg->FileRequest;
  225.                   Hold = Msg->Hold;
  226.                   Immediate = Msg->Immediate;
  227.                   Intransit = Msg->Intransit;
  228.                   KillSent = Msg->KillSent;
  229.                   Local = Msg->Local;
  230.                   Private = Msg->Private;
  231.                   ReceiptRequest = Msg->ReceiptRequest;
  232.                   Received = Msg->Received;
  233.                   Sent = Msg->Sent;
  234.                }
  235.             }
  236.             break;
  237.          }
  238.       } while ((msgIndex = (COMBOINDEX *)Index.Next ()) != NULL);
  239.  
  240.    return (RetVal);
  241. }
  242.  
  243. USHORT COMBO::Read (ULONG ulMsg, SHORT nWidth)
  244. {
  245.    return (Read (ulMsg, Text, nWidth));
  246. }
  247.  
  248. USHORT COMBO::Read (ULONG ulMsg, class TCollection &MsgText, SHORT nWidth)
  249. {
  250.    USHORT RetVal = FALSE;
  251.    CHAR *p;
  252.    COMBOINDEX *msgIndex;
  253.  
  254.    New ();
  255.  
  256.    if ((msgIndex = (COMBOINDEX *)Index.First ()) != NULL)
  257.       do {
  258.          if (msgIndex->Number == ulMsg) {
  259.             if (Msg != NULL && stricmp (LastPath, msgIndex->Path)) {
  260.                delete Msg;
  261.                Msg = NULL;
  262.             }
  263.             if (Msg == NULL) {
  264.                if (msgIndex->Storage == ST_JAM)
  265.                   Msg = new JAM (msgIndex->Path);
  266.                else if (msgIndex->Storage == ST_SQUISH)
  267.                   Msg = new SQUISH (msgIndex->Path);
  268.                else if (msgIndex->Storage == ST_FIDO)
  269.                   Msg = new FIDOSDM (msgIndex->Path);
  270.                else if (msgIndex->Storage == ST_ADEPT)
  271.                   Msg = new ADEPT (msgIndex->Path);
  272.             }
  273.             if (Msg != NULL) {
  274.                strcpy (LastPath, msgIndex->Path);
  275.                Current = msgIndex->Number;
  276.                if (Msg->Read (msgIndex->RealNumber, nWidth) == TRUE) {
  277.                   New ();
  278.                   RetVal = TRUE;
  279.  
  280.                   strcpy (From, Msg->From);
  281.                   strcpy (To, Msg->To);
  282.                   strcpy (Subject, Msg->Subject);
  283.  
  284.                   strcpy (FromAddress, Msg->FromAddress);
  285.                   strcpy (ToAddress, Msg->ToAddress);
  286.  
  287.                   Written.Day = Msg->Written.Day;
  288.                   Written.Month = Msg->Written.Month;
  289.                   Written.Year = Msg->Written.Year;
  290.                   Written.Hour = Msg->Written.Hour;
  291.                   Written.Minute = Msg->Written.Minute;
  292.                   Written.Second = Msg->Written.Second;
  293.  
  294.                   Arrived.Day = Msg->Arrived.Day;
  295.                   Arrived.Month = Msg->Arrived.Month;
  296.                   Arrived.Year = Msg->Arrived.Year;
  297.                   Arrived.Hour = Msg->Arrived.Hour;
  298.                   Arrived.Minute = Msg->Arrived.Minute;
  299.                   Arrived.Second = Msg->Arrived.Second;
  300.  
  301.                   Crash = Msg->Crash;
  302.                   Direct = Msg->Direct;
  303.                   FileAttach = Msg->FileAttach;
  304.                   FileRequest = Msg->FileRequest;
  305.                   Hold = Msg->Hold;
  306.                   Immediate = Msg->Immediate;
  307.                   Intransit = Msg->Intransit;
  308.                   KillSent = Msg->KillSent;
  309.                   Local = Msg->Local;
  310.                   Private = Msg->Private;
  311.                   ReceiptRequest = Msg->ReceiptRequest;
  312.                   Received = Msg->Received;
  313.                   Sent = Msg->Sent;
  314.  
  315.                   while ((p = (CHAR *)Msg->Text.First ()) != NULL) {
  316.                      MsgText.Add (p, (USHORT)(strlen (p) + 1));
  317.                      Msg->Text.Remove ();
  318.                   }
  319.                }
  320.             }
  321.             break;
  322.          }
  323.       } while ((msgIndex = (COMBOINDEX *)Index.Next ()) != NULL);
  324.  
  325.    return (RetVal);
  326. }
  327.  
  328. VOID COMBO::SetHWM (ULONG ulMsg)
  329. {
  330.    ulMsg = ulMsg;
  331. }
  332.  
  333. VOID COMBO::UnLock (VOID)
  334. {
  335. }
  336.  
  337. USHORT COMBO::WriteHeader (ULONG ulMsg)
  338. {
  339.    return (FALSE);
  340. }
  341.  
  342. USHORT COMBO::Write (ULONG ulMsg)
  343. {
  344.    return (Write (ulMsg, Text));
  345. }
  346.  
  347. USHORT COMBO::Write (ULONG ulMsg, class TCollection &MsgText)
  348. {
  349.    return (FALSE);
  350. }
  351.  
  352.