home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / mapi / remote.xp / xplist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-11  |  4.6 KB  |  141 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  File Name
  4. //      XPLIST.H 
  5. //
  6. //  Description
  7. //      Data structures, class definitions, and prototypes for downloading
  8. //      messages. Here define CList and CMsgQueue.
  9. //      CList holds a pointer to two messages queues: Messages to download
  10. //      and downloaded messages that are pending processing from the spooler.
  11. //
  12. //  Author
  13. //      Les Thaler
  14. //
  15. //  Revision: 1.7
  16. //
  17. // Written for Microsoft Windows Developer Support
  18. // Copyright (c) 1995-1996 Microsoft Corporation. All rights reserved.
  19. //
  20. #ifndef _XPLIST_H_
  21. #define _XPLIST_H_
  22.  
  23. long WINAPI FileCopy (HANDLE hTemp, HANDLE hPipe, DWORD dwMsgLen);
  24. MID WINAPI PropToMID (long lProp);
  25.  
  26. class CList;
  27. class CXPLogon;
  28.  
  29. // node in queue of downloaded/to-be-downloaded messages
  30. typedef struct _LIST_NODE
  31. {
  32.     struct _LIST_NODE *     pNext;
  33.     HANDLE                  hFile;
  34.     TCHAR                   szFileName[_MAX_PATH];
  35.     MSG_HDR                 Hdr;
  36.     MID                     OpStat;
  37.     BOOL                    fRetry;
  38. } LIST_NODE, *PLIST_NODE;
  39.  
  40.     
  41. // FIFO queue of downloaded/to-be-downloaded messages
  42. class CMsgQueue
  43. {   
  44. friend CList;
  45. ///////////////////////////////////////////////////////////////////////////////
  46. // Member functions specific to this class
  47. //
  48. public:
  49.     void WINAPI Insert
  50.                     (PLIST_NODE             pNode);
  51.     PLIST_NODE WINAPI Delete
  52.                     ();
  53.     inline BOOL WINAPI Empty
  54.                     () { return m_ulItems == 0;};
  55.  
  56. ///////////////////////////////////////////////////////////////////////////////
  57. // Constructors and destructors
  58. //
  59.     CMsgQueue();
  60.     ~CMsgQueue();        
  61.  
  62. ///////////////////////////////////////////////////////////////////////////////
  63. // Data members
  64. //
  65. private :
  66.     PLIST_NODE      m_pHead;
  67.     PLIST_NODE      m_pTail;
  68. public:
  69.     ULONG           m_ulItems;
  70. };
  71.  
  72. // Object for manipulating downloaded/to-be-downloaded queues
  73. // including managing data transfer with remote server
  74. class CList
  75. {
  76. ///////////////////////////////////////////////////////////////////////////////
  77. // Member functions specific to this class
  78. //
  79. public :
  80.     BOOL WINAPI Init
  81.                     ();
  82.     STDMETHODIMP DownLoadMsgs
  83.                     (LPMAPITABLE                pTable,
  84.                      ULONG                      ulRowCount,
  85.                      HANDLE                     hPipe);
  86.     BOOL WINAPI UpdateTableRow
  87.                     (LPBYTE                     pEID,
  88.                      MID                        midAction);
  89.     inline void WINAPI SetLogon
  90.                     (CXPLogon *                 pLogon)
  91.                     { m_pLogon = pLogon; }
  92.     inline PLIST_NODE WINAPI GetDownloadNode
  93.                     () { if (m_pDownloaded)
  94.                          { return m_pDownloaded->Delete(); }
  95.                          return NULL; }
  96.     inline BOOL WINAPI AreTherePendingDownloads
  97.                     () { if (m_pDownloaded)
  98.                          { return (!m_pDownloaded->Empty()); }
  99.                          return FALSE; }
  100.     inline BOOL WINAPI QueuePendingMsgFile
  101.                     (LPTSTR                     pstrFileName)
  102.                     { PLIST_NODE pNode = new LIST_NODE;
  103.                       if (pNode)
  104.                       { ZeroMemory (pNode, sizeof(LIST_NODE));
  105.                         lstrcpy (pNode->szFileName, pstrFileName);
  106.                         m_pDownloaded->Insert (pNode);
  107.                         return TRUE;
  108.                       }
  109.                       TraceMessage ("CLisg::QueuePendingMsgFile: Failed to allocate new node");
  110.                       return FALSE; }
  111.     void WINAPI UpdateProgress
  112.                     ();
  113.     inline void WINAPI ReQueueNode
  114.                     (PLIST_NODE                 pNode)
  115.                     { m_pToDownload->Insert (pNode); }
  116.  
  117. private :
  118.     void WINAPI DownLoadNow
  119.                     (HANDLE                     hPipe);
  120. ///////////////////////////////////////////////////////////////////////////////
  121. // Constructors and destructors
  122. //
  123. public :
  124.     CList();
  125.     ~CList();
  126.  
  127. ///////////////////////////////////////////////////////////////////////////////
  128. // Data members
  129. //
  130. private :
  131.     ULONG               m_ulMsgCount;
  132.     ULONG               m_ulMsgLeft;
  133.     CXPLogon *          m_pLogon;           // We need access to his stuff
  134.     CMsgQueue *         m_pToDownload;      // 'TO DO' queue
  135.     CMsgQueue *         m_pDownloaded;      // 'DONE' queue
  136. };
  137.  
  138. #endif // _XPLIST_H_
  139.  
  140. // End of file for XPLIST.H
  141.