home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / winsock / wvnsc926 / rcs / wvmail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  36.0 KB  |  1,785 lines

  1. head     1.24;
  2. branch   ;
  3. access   ;
  4. symbols  V80:1.6 V76d:1.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.24
  10. date     94.09.19.01.15.21;  author jcooper;  state Exp;
  11. branches ;
  12. next     1.23;
  13.  
  14. 1.23
  15. date     94.09.18.22.49.31;  author jcooper;  state Exp;
  16. branches ;
  17. next     1.22;
  18.  
  19. 1.22
  20. date     94.09.16.01.05.02;  author jcooper;  state Exp;
  21. branches ;
  22. next     1.21;
  23.  
  24. 1.21
  25. date     94.08.24.18.40.15;  author mrr;  state Exp;
  26. branches ;
  27. next     1.20;
  28.  
  29. 1.20
  30. date     94.05.27.01.29.29;  author rushing;  state Exp;
  31. branches ;
  32. next     1.19;
  33.  
  34. 1.19
  35. date     94.05.27.01.18.47;  author rushing;  state Exp;
  36. branches ;
  37. next     1.18;
  38.  
  39. 1.18
  40. date     94.02.24.21.32.14;  author jcoop;  state Exp;
  41. branches ;
  42. next     1.17;
  43.  
  44. 1.17
  45. date     94.02.09.18.39.32;  author rushing;  state Exp;
  46. branches ;
  47. next     1.16;
  48.  
  49. 1.16
  50. date     94.02.09.18.01.08;  author cnolan;  state Exp;
  51. branches ;
  52. next     1.15;
  53.  
  54. 1.15
  55. date     94.01.24.17.40.28;  author jcoop;  state Exp;
  56. branches ;
  57. next     1.14;
  58.  
  59. 1.14
  60. date     94.01.15.20.32.30;  author jcoop;  state Exp;
  61. branches ;
  62. next     1.13;
  63.  
  64. 1.13
  65. date     94.01.11.18.26.19;  author cnolan;  state Exp;
  66. branches ;
  67. next     1.12;
  68.  
  69. 1.12
  70. date     93.12.08.01.28.38;  author rushing;  state Exp;
  71. branches ;
  72. next     1.11;
  73.  
  74. 1.11
  75. date     93.08.25.18.54.36;  author mbretherton;  state Exp;
  76. branches ;
  77. next     1.10;
  78.  
  79. 1.10
  80. date     93.06.29.00.22.35;  author rushing;  state Exp;
  81. branches ;
  82. next     1.9;
  83.  
  84. 1.9
  85. date     93.06.28.17.51.39;  author rushing;  state Exp;
  86. branches ;
  87. next     1.8;
  88.  
  89. 1.8
  90. date     93.06.22.19.09.14;  author rushing;  state Exp;
  91. branches ;
  92. next     1.7;
  93.  
  94. 1.7
  95. date     93.06.22.16.45.51;  author bretherton;  state Exp;
  96. branches ;
  97. next     1.6;
  98.  
  99. 1.6
  100. date     93.06.11.00.11.26;  author rushing;  state Exp;
  101. branches ;
  102. next     1.5;
  103.  
  104. 1.5
  105. date     93.05.19.23.49.08;  author rushing;  state Exp;
  106. branches ;
  107. next     1.4;
  108.  
  109. 1.4
  110. date     93.05.18.22.10.45;  author rushing;  state Exp;
  111. branches ;
  112. next     1.3;
  113.  
  114. 1.3
  115. date     93.04.27.21.29.23;  author rushing;  state Exp;
  116. branches ;
  117. next     1.2;
  118.  
  119. 1.2
  120. date     93.03.30.20.09.08;  author rushing;  state Exp;
  121. branches ;
  122. next     1.1;
  123.  
  124. 1.1
  125. date     93.02.16.20.54.22;  author rushing;  state Exp;
  126. branches ;
  127. next     ;
  128.  
  129.  
  130. desc
  131. @winvn version 0.76 placed into RCS
  132. @
  133.  
  134.  
  135. 1.24
  136. log
  137. @ignore MAPI in auto-select if using win32s
  138. @
  139. text
  140. @/*--- WVMAIL.C ------------------------------------------------------------
  141.  *
  142.  *    This file contains the window procedure for the windows
  143.  *    used to edit outgoing mail messages.
  144.  *
  145.  *    Mark Riordan   11 June 1991
  146.  *
  147.  *    MAPI interface implemented by MAtthew Bretherton  March 1993
  148.  */
  149.  
  150.  
  151. /*
  152.  * $Id: wvmail.c 1.23 1994/09/18 22:49:31 jcooper Exp $
  153.  * $Log: wvmail.c $
  154.  * Revision 1.23  1994/09/18  22:49:31  jcooper
  155.  * support for cascading windows
  156.  * 
  157.  * Revision 1.22  1994/09/16  01:05:02  jcooper
  158.  * General cleanup for 92.6
  159.  * 
  160.  * Revision 1.21  1994/08/24  18:40:15  mrr
  161.  * authorization enables post/mail
  162.  *
  163.  * Revision 1.20  1994/05/27  01:29:29  rushing
  164.  * unnecessary winundoc.h
  165.  *
  166.  * Revision 1.19  1994/05/27  01:18:47  rushing
  167.  * new smtp
  168.  *
  169.  * Revision 1.18  1994/02/24  21:32:14  jcoop
  170.  * jcoop changes
  171.  *
  172.  * Revision 1.17  1994/02/09  18:39:32  rushing
  173.  * ':' missing on case
  174.  *
  175.  * Revision 1.16  1994/02/09  18:01:08  cnolan
  176.  * cnolan 90.2 changes
  177.  *
  178.  * Revision 1.15  1994/01/24  17:40:28  jcoop
  179.  * 90.2 changes
  180.  *
  181.  * Revision 1.14  1994/01/15  20:32:30  jcoop
  182.  * Attachments, color/font, global editWnd, bugfix in WM_SEND
  183.  *
  184.  * Revision 1.13  1994/01/11  18:26:19  cnolan
  185.  * from conor nolan (missed changes)
  186.  * 
  187.  * Revision 1.12  1993/12/08  01:28:38  rushing
  188.  * new version box and cr lf consistency
  189.  *
  190.  * Revision 1.11  1993/08/25  18:54:36  mbretherton
  191.  * MRB merge, mail & post logging
  192.  *
  193.  * Revision 1.10  1993/06/29  00:22:35  rushing
  194.  * make smtp headers have Date: header
  195.  *
  196.  * Revision 1.9  1993/06/28  17:51:39  rushing
  197.  * fixed compiler warnings
  198.  *
  199.  * Revision 1.8  1993/06/22  19:09:14  rushing
  200.  * mail force type selection via dialog
  201.  *
  202.  * Revision 1.7  1993/06/22  16:45:51  bretherton
  203.  * *** empty log message ***
  204.  *
  205.  * Revision 1.xx MBretherton - auto close mail window on
  206.  *               successful dispatch of mail
  207.  *               & tweak smtp/mapi cotnrol
  208.  * Revision 1.6  1993/06/11  00:11:26  rushing
  209.  * second merge from Matt Bretherton sources
  210.  *
  211.  * Revision 1.5  1993/05/19  23:49:08  rushing
  212.  * notify user after succesfull forward_smtp_message
  213.  *
  214.  * Revision 1.4  1993/05/18  22:10:45  rushing
  215.  * smtp support
  216.  *
  217.  * Revision 1.3  1993/04/27  21:29:23  rushing
  218.  * added rcs log and id magikstrings
  219.  *
  220.  *
  221.  */
  222.  
  223. #include <windows.h>
  224. #include <windowsx.h>
  225. #include "wvglob.h"
  226. #include "winvn.h"
  227. #pragma hdrstop
  228.  
  229. mlSMTPSend (HWND hWnd, char *mBuf);
  230. mlSMTPForward (HWND hWnd, TypDoc *Doc);
  231.  
  232. long FAR PASCAL 
  233. WinVnMailWndProc (hWnd, message, wParam, lParam)
  234.      HWND hWnd;
  235.      unsigned message;
  236.      WPARAM wParam;
  237.      LPARAM lParam;
  238. {
  239.   WndEdit * WndMail;
  240. //  int ih, found;
  241.  
  242.   WndMail = getWndEdit(WndMails,hWnd,MAXMAILWNDS) ;
  243.  
  244.   if ((!WndMail) && message == WM_CREATE)
  245.     {
  246.       for (ih = 0; ih < MAXMAILWNDS; ih++)
  247.    {
  248.      if (!WndMails[ih].hWnd)
  249.        {
  250.          WndMail = &WndMails[ih];
  251.          WndMail->hWnd = hWnd;
  252.          WndMail->Doc = MailDoc ;
  253.  
  254.          break;
  255.        }
  256.    }
  257.     }
  258.  
  259.   switch (message)
  260.     {
  261.     case WM_SYSCOMMAND:
  262.       return (DefWindowProc (hWnd, message, wParam, lParam));
  263.  
  264.     case WM_CREATE:
  265.       if (CreateEditWnd (WndMail) == FAIL)
  266.          break;
  267.       
  268.       NumMailWnds++;
  269.   
  270.       SendMessage (WndMail->hWndEdit, WM_SETFONT, (WPARAM)hFontArtNormal, TRUE);
  271.   
  272.       if (!Attaching)
  273.          CreatePostingText (MailDoc, hWnd, WndMail->hWndEdit, DOCTYPE_MAIL);
  274.  
  275.       /* Subclass the edit window to pass accelerators to parent */
  276.       SetWindowLong (WndMail->hWndEdit,
  277.            GWL_WNDPROC,
  278.            (long) lpfnEditSubClass);
  279.       break;
  280.  
  281. #ifdef _WIN32
  282.     case WM_CTLCOLOREDIT:
  283. #else
  284.    case WM_CTLCOLOR:    //WIN32 doesn't handle this message anymore
  285.       // Set foreground and background colors of edit control
  286.       if (HIWORD(lParam) == CTLCOLOR_EDIT)
  287. #endif
  288.       {
  289.          SetTextColor((HDC)wParam, ArticleTextColor);
  290.          SetBkColor((HDC)wParam, ArticleBackgroundColor);
  291.          // Return handle to background brush for the edit control
  292.          return (LRESULT)hArticleBackgroundBrush;
  293.       }
  294.       break;
  295.  
  296.     case WM_SIZE:
  297.  
  298.      MoveWindow (WndMail->hWndEdit, 0, 0, LOWORD (lParam),
  299.         HIWORD (lParam), TRUE);
  300.  
  301.       break;
  302.  
  303.     case WM_SETFOCUS:
  304.       SetFocus (WndMail->hWndEdit);
  305.       break;
  306.  
  307.     case WM_KEYDOWN:
  308.       if (wParam == VK_F6)
  309.    {
  310.      NextWindow (WndMail->Doc);
  311.    }
  312.       break;
  313.  
  314.     case WM_INITMENUPOPUP:
  315.       prepareEditMenu (hWnd, WndMail->hWndEdit);
  316.       break;
  317.  
  318.     case WM_COMMAND:
  319.     // Edit Window notifications to parent
  320.     if ((HWND)(UINT)lParam == WndMail->hWndEdit){     
  321. #ifdef WIN32
  322.        if (HIWORD(wParam) == EN_CHANGE)
  323. #else
  324.        if (HIWORD(lParam) == EN_CHANGE)
  325. #endif
  326.         WndMail->dirty = DT_DIRTY ;
  327.        return(0L) ;
  328.     }
  329.  
  330.       switch (LOWORD(wParam))
  331.    {
  332.    case IDM_CANCEL:
  333.    case IDV_EXIT:
  334.      DoEditClose(WndMail->hWnd,WndMail->dirty);
  335.      break;
  336.  
  337.    case IDM_SEND:
  338.      StartMail (WndMail);
  339.      break;
  340.  
  341.    case IDM_ATTACH:
  342.      if (TestDecodeBusy(hWndConf, "Can't make attachment"))
  343.        break;
  344.  
  345.      if (AskForExistingFileName (hWnd, AttachFileName, "Open file to attach") == FAIL)
  346.       break;
  347.            if (DialogBox (hInst, "WinVnAttach", hWnd, lpfnWinVnAttachDlg))
  348.            Attach (WndMail, AttachFileName, DOCTYPE_MAIL);
  349.      
  350.      InvalidateRect (hWnd, NULL, TRUE);
  351.           break;
  352.    
  353.    default:
  354.      DoEditCommands (WndMail->hWndEdit, wParam, lParam);
  355.      break;
  356.    }
  357.       break;
  358.  
  359.  
  360.     case WM_DESTROY:
  361.       WndMail->hWnd = 0;                       
  362.       WndMail->hWndEdit = 0;
  363.       NumMailWnds--;
  364.       break;
  365.  
  366.     case WM_CLOSE:
  367.       if (CommBusy && MailEdit == WndMail)
  368.    MessageBox (hWnd,
  369.      "Please wait until mail send is complete",
  370.      "Cannot close mail window", MB_OK|MB_ICONSTOP);
  371.       else
  372.     DoEditClose(WndMail->hWnd,WndMail->dirty);
  373.       break;
  374.  
  375.     default:
  376.       return (DefWindowProc (hWnd, message, wParam, lParam));
  377.     }
  378.   return (0L);
  379. }
  380.  
  381. /*---- function MailLogout---------------------------------------------
  382.  *
  383.  *   Finish up the mail session
  384.  *
  385.  */
  386. int
  387. MailClose (hWnd) 
  388.     HWND hWnd;
  389. {  
  390.   return ((MailCtrl.fnMlClose)(hWnd)) ;
  391. }
  392.  
  393. /*---- function MailInit ----------------------------------------------
  394.  *
  395.  *
  396.  *
  397.  */
  398. int MailInit (HWND hWnd) 
  399. {  
  400.   int Mapi_Type;
  401.  
  402.   if (MailForceType >= 0)
  403.     { /* Accept Private Profile directive to override Mail negotiation */
  404.       MailCtrl.MailType = MailForceType;
  405.     }
  406.   else
  407.     { /* MAPI is next on the negotiation list */
  408. #ifdef WIN32
  409.       if (GetVersion() == 1) /* win32s */
  410.          Mail_Type = 0
  411.       else
  412. #endif
  413.          Mapi_Type =  GetProfileInt("Mail","MAPI",0) ;
  414.  
  415.       if (Mapi_Type > 0)
  416.    { 
  417.      MailCtrl.MailType = MT_MAPI ;
  418.    } else
  419.    if (strcmp(SMTPHost,""))
  420.    {  /* SMTP next on the negotiation list
  421.          and assume that if SMTP host is specified use it */
  422.      MailCtrl.MailType = MT_SMTP;
  423.    } else 
  424.    {
  425.      MailCtrl.MailType = MT_NONE ;
  426.    } ;
  427.     }
  428.  
  429.   SetMailType (MailCtrl.MailType) ;
  430.  
  431.   (MailCtrl.fnMlInit)(hWnd);
  432.  
  433.   return (0);
  434. }
  435.  
  436. /* -------------- MailCrashClose -----------------
  437.  *
  438.  *  On serious error in mail interface crash mail and
  439.  * disable mail interface - winvn Ok to run without mail
  440.  *
  441.  * -----------------------------------------------*/
  442.  
  443. void
  444. MailCrashExit(HWND hWnd)
  445. {
  446.   MailCtrl.fnMlClose(hWnd) ;  // clear down mail resources in use
  447.   SetMailType(MT_NONE)  ;
  448. }
  449.  
  450. /*---- function MailxxxDefProc -------------------------------------------
  451.  *
  452.  *  Default Proc to support generic nature of dealing with multiple 
  453.  *  mailing interfaces
  454.  *                                                       
  455.  */
  456. MailDefCtlProc (HWND hWnd) {return (0);}
  457. MailDefChrProc (HWND hWnd, char *mBuf) {return (0);}
  458. MailDefDocProc (HWND hWnd, TypDoc * Doc, int DocType) {return (0);}
  459. MailDefDocProc2 (HWND hWnd, TypDoc * Doc) { return 0; }
  460.  
  461. /* --- SetMailType  ----------------------------------------------------
  462.  *
  463.  *  set up logic attributes for selected mail interface
  464.  *
  465.  */ 
  466.  
  467. void
  468. SetMailType (int mailType)
  469.  static BOOL (*NoHeaderFuncs[])(TypDoc * Doc, char *Buf, long int BufLen) =
  470.      {
  471.       NULL
  472.       };
  473.  static BOOL (*MAPIHeaderFuncs[])(TypDoc * Doc, char *Buf, long int BufLen) =
  474.      {
  475.       GetArtHeaderTo, 
  476.       GetArtHeaderSubject,
  477.       NULL 
  478.      };
  479.  static BOOL (*SMTPHeaderFuncs[])(TypDoc * Doc, char *Buf, long int BufLen) =
  480.      {
  481.       MakeArtHeaderTo,
  482.       MakeArtHeaderFrom,
  483.       MakeArtHeaderSubject,
  484.       MakeArtHeaderOrganization,
  485.       MakeArtHeaderDate,
  486.       MakeArtHeaderReplyTo,
  487.       MakeArtHeaderXmailer,
  488.       NULL
  489.      };
  490.  
  491.  
  492.   switch (mailType)
  493.   {  
  494.      case MT_MAPI :
  495.    MailCtrl.enableMail = MF_ENABLED ;
  496.    MailCtrl.enableLogout = MF_GRAYED ;
  497.    MailCtrl.enableForward = MF_GRAYED ;
  498.    MailCtrl.fnMlInit=mlMAPIInit ;
  499.    MailCtrl.fnMlLogout=mlMAPILogout ;
  500.    MailCtrl.fnMlClose=mlMAPIClose;
  501.    MailCtrl.fnMlSend=MailDefChrProc;
  502.    MailCtrl.fnMlForward=MailDefDocProc2;
  503.    MailCtrl.fnMlWinCreate=mlMAPISend ;
  504.    MailCtrl.MailHeaderFuncs = MAPIHeaderFuncs ;
  505.    break ;
  506.       case MT_SMTP :
  507.    MailCtrl.enableMail = MF_ENABLED ;
  508.    MailCtrl.enableLogout = MF_GRAYED;
  509.    MailCtrl.enableForward = MF_ENABLED ;   
  510.    MailCtrl.fnMlInit=MailCtrl.fnMlLogout=MailDefCtlProc ;
  511.    MailCtrl.fnMlLogout=MailDefCtlProc;
  512.    MailCtrl.fnMlClose=MailDefCtlProc;
  513.    MailCtrl.fnMlSend=mlSMTPSend;
  514.    MailCtrl.fnMlForward=mlSMTPForward;
  515.    MailCtrl.fnMlWinCreate=(int (*)(HWND, TypDoc *, int))CreatePostingWnd;
  516.    MailCtrl.MailHeaderFuncs = SMTPHeaderFuncs;
  517.    break;
  518.    /* error handling for Fall through case message box plus */
  519.    /* default to none */ 
  520.      case MT_NONE :
  521.      default:
  522.    MailCtrl.enableMail = MF_GRAYED ;
  523.    MailCtrl.enableLogout = MF_GRAYED;
  524.    MailCtrl.enableForward = MF_GRAYED ;
  525.    MailCtrl.fnMlClose=MailDefCtlProc;
  526.    MailCtrl.fnMlInit=MailCtrl.fnMlLogout=MailDefCtlProc ;
  527.    MailCtrl.fnMlSend=MailDefChrProc ;
  528.    MailCtrl.fnMlForward=MailDefDocProc2;
  529.    MailCtrl.fnMlWinCreate=MailDefDocProc;
  530.    MailCtrl.MailHeaderFuncs = NoHeaderFuncs ;
  531.    break ;
  532.   } ;
  533. }
  534.  
  535. /* -------------- MailEnableLogout ------------------------
  536.  *
  537.  *  Allow discard (freeing) of mail resources during
  538.  *  the session - Not necessarily available to all mail
  539.  *  services
  540.  *
  541.  *--------------------------------------------------------*/  
  542. void
  543. MailEnableLogout(BOOL enable)
  544. {
  545.   if (enable) MailCtrl.enableLogout = MF_ENABLED ;
  546.   else        MailCtrl.enableLogout = MF_GRAYED ;
  547. }
  548.  
  549. /*--- function StartMail ----------------------------------------------
  550.  *
  551.  *    Start the Mailing procedure for an article that has been created
  552.  *    by the user.
  553.  */
  554. BOOL
  555. StartMail (WndEdit *thisMail)
  556. {
  557.   BOOL MailOK = FALSE ;
  558.   char *editptr;
  559.   char title[MAXINTERNALLINE];
  560.   
  561.   GetWindowText(thisMail->hWnd, title, MAXINTERNALLINE-1);
  562.   strcpy(str, title);
  563.   strcat(str, "  [Mailing...]");
  564.   SetWindowText (thisMail->hWnd, str);
  565.  
  566.   MailEdit = thisMail;
  567.   /* If authentication was required, stuff a header line into
  568.    * the beginning of the message so that people reading it can
  569.    * know who really posted it.  (The From: line may be a lie.)
  570.    */
  571.   if(AuthReqMail) {
  572.     AddAuthHeader(MailEdit->hWndEdit);
  573.   }
  574.   
  575.   // lock out changes
  576.   SendMessage(MailEdit->hWndEdit, EM_SETREADONLY, TRUE, 0L);
  577.  
  578.   editptr = GetEditText (MailEdit->hWndEdit);
  579.   
  580.   MailOK=(MailCtrl.fnMlSend)(MailEdit->hWnd, editptr) ;
  581.  
  582.   if (!MailOK)
  583.      // unlock to allow user modification
  584.      SendMessage(MailEdit->hWndEdit, EM_SETREADONLY, FALSE, 0L);
  585.  
  586.   GlobalFreePtr (editptr);         
  587.   
  588.   SetWindowText (thisMail->hWnd, title);
  589.   return (MailOK);
  590. }
  591.  
  592. /*--- function GetMailHeaderString ------------------------------------
  593.  *
  594.  *    mailMsg   points to the mail message buffer (null terminated 
  595.  *              string)
  596.  *
  597.  *              Prefix   is the character string which will identify the
  598.  *                       line we are seeking.  It is the first word
  599.  *                       (blank-delimited) in a line in the header.
  600.  *              BufSize   is the number of bytes left in the buffer Buf.
  601.  *
  602.  *    Exit      Returns  TRUE if we returned a line of this prefix.
  603.  *              Buf      if line was found, contains the line less
  604.  *                       the Prefix null terminated.
  605.  * 
  606.   */
  607. BOOL
  608. GetMailHeaderString (mailMsg, Prefix, Buf, BufSize)
  609.      char *mailMsg;
  610.      char *Prefix;
  611.      char *Buf;
  612.      int BufSize;
  613. {
  614.   BOOL found = FALSE, got_To = FALSE;
  615.   char outline[MAXOUTLINE];
  616.   char  *outptr;
  617.   int linelen;
  618.  
  619.  
  620.       while (!got_To && *mailMsg)
  621.    {
  622.      for (linelen = 0, outptr = outline; *mailMsg && *mailMsg != '\r' &&
  623.           linelen < MAXOUTLINE; linelen++)
  624.        *(outptr++) = *(mailMsg++);
  625.      *outptr = '\0';
  626.  
  627.      if (CompareStringNoCase (outline, Prefix, strlen(Prefix)) == 0)
  628.        {
  629.          got_To = TRUE;
  630.       }
  631.      if (*mailMsg='\r')
  632.       {
  633.      mailMsg++ ; mailMsg++ ;  /* jump CRLF */
  634.      }
  635.    }
  636.  
  637.       if (got_To)
  638.    {
  639.      outptr = outline;
  640.      NextToken (&outptr);
  641.      while (--BufSize > 1 && (*(Buf++) = *(outptr++)));
  642.      found = TRUE;
  643.    }
  644.    *Buf = '\0';       /* whatever happens Buf is null delim string */
  645.        
  646.   return (found);
  647. }
  648.  
  649. mlSMTPSend (HWND hWnd, char *mBuf )
  650. {
  651.   BOOL Addressed = FALSE;
  652.   char Addressee[MAXOUTLINE];
  653. // int res ;
  654.  
  655.   Addressed=GetMailHeaderString (mBuf, "To: ", Addressee, MAXOUTLINE) ;
  656.  
  657.   if (!Addressed)
  658.     {
  659.       MessageBox (hWnd, "Fill in the \"To:\" line", "Need a recipient",
  660.         MB_OK | MB_ICONHAND);
  661.       return(FALSE) ; 
  662.     }
  663.    
  664.   if (!send_smtp_message (Addressee,mBuf))
  665.   {
  666.  //   res=MessageBox (hWnd, "Mail delivered to server", "WinVN", MB_OKCANCEL);
  667.  //   if (res==ID_OK)
  668.      if (MailLog) WriteEditLog(hWnd,MailLogFile,mBuf, lstrlen (mBuf)) ;
  669.      
  670.      MailEdit->dirty=DT_CLEAN ;
  671.      MailEdit = (WndEdit *) NULL;
  672.      
  673.      DestroyWindow(hWnd) ;
  674.      
  675.      if (nextBatchIndex)      // if we're sending a batch, send the next
  676.         BatchSend (DOCTYPE_MAIL);
  677.      
  678.      return (TRUE);
  679.   }
  680.   else
  681.   {
  682.     nextBatchIndex = 0;
  683.     return (FALSE);
  684.   }
  685. }
  686.  
  687. int mlSMTPForward (HWND hWnd, TypDoc * Doc)
  688. {
  689.  
  690.   DialogString[0]=(char)NULL;
  691.   while (!strcmp(DialogString,""))
  692.     if (!DialogBox (hInst, "WinVnMail", hWndConf, lpfnWinVnMailDlg))
  693.       return (0);
  694.  
  695.   if (!forward_smtp_message (DialogString, Doc)) {
  696.     MessageBox (hWnd, "Mail delivered to server", "WinVN", MB_OK);
  697.     return (1);
  698.   }
  699.   else 
  700.     return (0);
  701.   
  702. //  else {
  703. //    MessageBox (hWndConf, "You must enter a recipient", "WinVN", MB_OK);
  704. //    return (0);
  705. //  }
  706. }
  707. @
  708.  
  709.  
  710. 1.23
  711. log
  712. @support for cascading windows
  713. @
  714. text
  715. @d13 1
  716. a13 1
  717.  * $Id: wvmail.c 1.22 1994/09/16 01:05:02 jcooper Exp $
  718. d15 3
  719. d269 6
  720. a274 1
  721.       Mapi_Type =  GetProfileInt("Mail","MAPI",0) ;
  722. @
  723.  
  724.  
  725. 1.22
  726. log
  727. @General cleanup for 92.6
  728. @
  729. text
  730. @d13 1
  731. a13 1
  732.  * $Id: wvmail.c 1.21 1994/08/24 18:40:15 mrr Exp $
  733. d15 3
  734. d125 2
  735. d221 1
  736. a221 1
  737.  
  738. @
  739.  
  740.  
  741. 1.21
  742. log
  743. @authorization enables post/mail
  744. @
  745. text
  746. @d13 1
  747. a13 1
  748.  * $Id: wvmail.c 1.20 1994/05/27 01:29:29 rushing Exp $
  749. d15 3
  750. d78 2
  751. a79 2
  752. #include "windows.h"
  753. #include <windowsx.h>   // for GlobalFreePtr
  754. d82 1
  755. d123 1
  756. a123 1
  757.       SendMessage (WndMail->hWndEdit, WM_SETFONT, hFontArtNormal, TRUE);
  758. d145 1
  759. a145 1
  760.          return (DWORD)hArticleBackgroundBrush;
  761. d195 3
  762. d302 1
  763. a302 1
  764.  *
  765. d364 1
  766. a364 1
  767.    MailCtrl.fnMlWinCreate=CreatePostingWnd ;
  768. d408 6
  769. d437 1
  770. d541 1
  771. a541 1
  772.     if (!DialogBoxParam (hInst, "WinVnMail", hWndConf, lpfnWinVnMailDlg, (LPARAM) NULL))
  773. @
  774.  
  775.  
  776. 1.20
  777. log
  778. @unnecessary winundoc.h
  779. @
  780. text
  781. @d13 1
  782. a13 1
  783.  * $Id: wvmail.c 1.19 1994/05/27 01:18:47 rushing Exp rushing $
  784. d15 3
  785. d76 1
  786. a76 1
  787. #include <windowsx.h>    // for GlobalFreePtr
  788. d98 10
  789. a107 10
  790.     {
  791.       if (!WndMails[ih].hWnd)
  792.         {
  793.            WndMail = &WndMails[ih];
  794.           WndMail->hWnd = hWnd;
  795.           WndMail->Doc = MailDoc ;
  796.  
  797.           break;
  798.         }
  799.     }
  800. d126 2
  801. a127 2
  802.              GWL_WNDPROC,
  803.              (long) lpfnEditSubClass);
  804. d133 1
  805. a133 1
  806.       case WM_CTLCOLOR:        //WIN32 doesn't handle this message anymore
  807. d148 1
  808. a148 1
  809.           HIWORD (lParam), TRUE);
  810. d158 3
  811. a160 3
  812.     {
  813.       NextWindow (WndMail->Doc);
  814.     }
  815. d175 1
  816. a175 1
  817.          WndMail->dirty = DT_DIRTY ;
  818. d180 17
  819. a196 17
  820.     {
  821.     case IDM_CANCEL:
  822.     case IDV_EXIT:
  823.       DoEditClose(WndMail->hWnd,WndMail->dirty);
  824.       break;
  825.  
  826.     case IDM_SEND:
  827.       StartMail (WndMail);
  828.       break;
  829.  
  830.     case IDM_ATTACH:
  831.       if (AskForExistingFileName (hWnd, AttachFileName, "Open file to attach") == FAIL)
  832.           break;
  833.              if (DialogBox (hInst, "WinVnAttach", hWnd, lpfnWinVnAttachDlg))
  834.               Attach (WndMail, AttachFileName, DOCTYPE_MAIL);
  835.       
  836.       InvalidateRect (hWnd, NULL, TRUE);
  837. d198 5
  838. a202 5
  839.     
  840.     default:
  841.       DoEditCommands (WndMail->hWndEdit, wParam, lParam);
  842.       break;
  843.     }
  844. d214 3
  845. a216 3
  846.      MessageBox (hWnd,
  847.       "Please wait until mail send is complete",
  848.       "Cannot close mail window", MB_OK|MB_ICONSTOP);
  849. d218 1
  850. a218 1
  851.      DoEditClose(WndMail->hWnd,WndMail->dirty);
  852. d257 11
  853. a267 11
  854.     { 
  855.       MailCtrl.MailType = MT_MAPI ;
  856.     } else
  857.     if (strcmp(SMTPHost,""))
  858.     {  /* SMTP next on the negotiation list
  859.           and assume that if SMTP host is specified use it */
  860.       MailCtrl.MailType = MT_SMTP;
  861.     } else 
  862.     {
  863.       MailCtrl.MailType = MT_NONE ;
  864.     } ;
  865. d312 3
  866. a314 3
  867.       {
  868.         NULL
  869.        };
  870. d316 5
  871. a320 5
  872.       {
  873.         GetArtHeaderTo, 
  874.         GetArtHeaderSubject,
  875.         NULL 
  876.       };
  877. d322 10
  878. a331 10
  879.       {
  880.         MakeArtHeaderTo,
  881.         MakeArtHeaderFrom,
  882.         MakeArtHeaderSubject,
  883.         MakeArtHeaderOrganization,
  884.         MakeArtHeaderDate,
  885.         MakeArtHeaderReplyTo,
  886.         MakeArtHeaderXmailer,
  887.         NULL
  888.       };
  889. d337 11
  890. a347 11
  891.     MailCtrl.enableMail = MF_ENABLED ;
  892.     MailCtrl.enableLogout = MF_GRAYED ;
  893.     MailCtrl.enableForward = MF_GRAYED ;
  894.     MailCtrl.fnMlInit=mlMAPIInit ;
  895.     MailCtrl.fnMlLogout=mlMAPILogout ;
  896.     MailCtrl.fnMlClose=mlMAPIClose;
  897.     MailCtrl.fnMlSend=MailDefChrProc;
  898.     MailCtrl.fnMlForward=MailDefDocProc2;
  899.     MailCtrl.fnMlWinCreate=mlMAPISend ;
  900.     MailCtrl.MailHeaderFuncs = MAPIHeaderFuncs ;
  901.     break ;
  902. d349 13
  903. a361 13
  904.     MailCtrl.enableMail = MF_ENABLED ;
  905.     MailCtrl.enableLogout = MF_GRAYED;
  906.     MailCtrl.enableForward = MF_ENABLED ;   
  907.     MailCtrl.fnMlInit=MailCtrl.fnMlLogout=MailDefCtlProc ;
  908.     MailCtrl.fnMlLogout=MailDefCtlProc;
  909.     MailCtrl.fnMlClose=MailDefCtlProc;
  910.     MailCtrl.fnMlSend=mlSMTPSend;
  911.     MailCtrl.fnMlForward=mlSMTPForward;
  912.     MailCtrl.fnMlWinCreate=CreatePostingWnd ;
  913.     MailCtrl.MailHeaderFuncs = SMTPHeaderFuncs;
  914.     break;
  915.     /* error handling for Fall through case message box plus */
  916.     /* default to none */ 
  917. d364 10
  918. a373 10
  919.     MailCtrl.enableMail = MF_GRAYED ;
  920.     MailCtrl.enableLogout = MF_GRAYED;
  921.     MailCtrl.enableForward = MF_GRAYED ;
  922.     MailCtrl.fnMlClose=MailDefCtlProc;
  923.     MailCtrl.fnMlInit=MailCtrl.fnMlLogout=MailDefCtlProc ;
  924.     MailCtrl.fnMlSend=MailDefChrProc ;
  925.     MailCtrl.fnMlForward=MailDefDocProc2;
  926.     MailCtrl.fnMlWinCreate=MailDefDocProc;
  927.     MailCtrl.MailHeaderFuncs = NoHeaderFuncs ;
  928.     break ;
  929. d403 8
  930. d456 11
  931. a466 11
  932.     {
  933.       for (linelen = 0, outptr = outline; *mailMsg && *mailMsg != '\r' &&
  934.            linelen < MAXOUTLINE; linelen++)
  935.         *(outptr++) = *(mailMsg++);
  936.       *outptr = '\0';
  937.  
  938.       if (CompareStringNoCase (outline, Prefix, strlen(Prefix)) == 0)
  939.         {
  940.           got_To = TRUE;
  941.         }
  942.       if (*mailMsg='\r')
  943. d468 3
  944. a470 3
  945.       mailMsg++ ; mailMsg++ ;  /* jump CRLF */
  946.       }
  947.     }
  948. d473 8
  949. a480 8
  950.     {
  951.       outptr = outline;
  952.       NextToken (&outptr);
  953.       while (--BufSize > 1 && (*(Buf++) = *(outptr++)));
  954.       found = TRUE;
  955.     }
  956.     *Buf = '\0';       /* whatever happens Buf is null delim string */
  957.         
  958. d495 1
  959. a495 1
  960.           MB_OK | MB_ICONHAND);
  961. d510 1
  962. a510 1
  963.      if (nextBatchIndex)        // if we're sending a batch, send the next
  964. @
  965.  
  966.  
  967. 1.19
  968. log
  969. @new smtp
  970. @
  971. text
  972. @d13 1
  973. a13 1
  974.  * $Id: wvmail.c 1.18 1994/02/24 21:32:14 jcoop Exp rushing $
  975. d15 3
  976. a75 1
  977. #include "winundoc.h"
  978. @
  979.  
  980.  
  981. 1.18
  982. log
  983. @jcoop changes
  984. @
  985. text
  986. @d13 1
  987. a13 1
  988.  * $Id: wvmail.c 1.17 1994/02/09 18:39:32 rushing Exp $
  989. d15 3
  990. d407 1
  991. a407 1
  992.      SendMessage(PostEdit->hWndEdit, EM_SETREADONLY, FALSE, 0L);
  993. d486 1
  994. a486 1
  995.   if (send_smtp_message (Addressee,mBuf))
  996. d517 1
  997. a517 1
  998.   if (forward_smtp_message (DialogString, Doc)) {
  999. @
  1000.  
  1001.  
  1002. 1.17
  1003. log
  1004. @':' missing on case
  1005. @
  1006. text
  1007. @d13 1
  1008. a13 1
  1009.  * $Id: wvmail.c 1.16 1994/02/09 18:01:08 cnolan Exp rushing $
  1010. d15 3
  1011. d320 1
  1012. d401 5
  1013. d482 1
  1014. a482 1
  1015.  
  1016. d509 3
  1017. a511 8
  1018.   DialogBoxParam (hInst, "WinVnGeneric", hWnd, lpfnWinVnGenericDlg, 
  1019.           (LPARAM) (char far *) "Enter recipient's email address:");
  1020.   if (strcmp(DialogString, "")) {
  1021.     if (forward_smtp_message (DialogString, Doc)) {
  1022.       MessageBox (hWnd, "Mail delivered to server", "WinVN", MB_OK);
  1023.       return (1);
  1024.   }
  1025.     else 
  1026. d513 4
  1027. d518 1
  1028. a518 2
  1029.   else {
  1030.     MessageBox (hWndConf, "You must enter a recipient", "WinVN", MB_OK);
  1031. d520 5
  1032. a524 1
  1033.   }
  1034. @
  1035.  
  1036.  
  1037. 1.16
  1038. log
  1039. @cnolan 90.2 changes
  1040. @
  1041. text
  1042. @d13 1
  1043. a13 1
  1044.  * $Id: wvmail.c 1.15 1994/01/24 17:40:28 jcoop Exp $
  1045. d15 3
  1046. d122 1
  1047. a122 1
  1048.       case WM_CTLCOLOR        //WIN32 doesn't handle this message anymore
  1049. @
  1050.  
  1051.  
  1052. 1.15
  1053. log
  1054. @90.2 changes
  1055. @
  1056. text
  1057. @d13 1
  1058. a13 1
  1059.  * $Id: wvmail.c 1.14 1994/01/15 20:32:30 jcoop Exp $
  1060. d15 3
  1061. d116 4
  1062. a119 1
  1063.     case WM_CTLCOLOR:
  1064. d122 1
  1065. d124 2
  1066. a125 2
  1067.          SetTextColor(wParam, ArticleTextColor);
  1068.          SetBkColor(wParam, ArticleBackgroundColor);
  1069. @
  1070.  
  1071.  
  1072. 1.14
  1073. log
  1074. @Attachments, color/font, global editWnd, bugfix in WM_SEND
  1075. @
  1076. text
  1077. @d13 1
  1078. a13 1
  1079.  * $Id: wvmail.c 1.13 1994/01/11 18:26:19 cnolan Exp $
  1080. d15 3
  1081. d192 5
  1082. a372 2
  1083.  *    MailWnd is the EditStructure containing info on this particular 
  1084.  *    mail window
  1085. d375 1
  1086. a375 1
  1087. StartMail (WndEdit *MailWnd)
  1088. d379 4
  1089. a382 1
  1090.   HWND hWndMailEdit = MailWnd->hWndEdit;
  1091. d384 4
  1092. a387 1
  1093.   editptr = GetEditText (hWndMailEdit);
  1094. a388 2
  1095.   MailOK=(MailCtrl.fnMlSend)(MailWnd->hWnd,editptr) ;
  1096.   GlobalFreePtr (editptr);
  1097. d469 4
  1098. a472 1
  1099.      getWndEdit(WndMails,hWnd,MAXMAILWNDS)->dirty=DT_CLEAN ;
  1100. d474 4
  1101. d481 2
  1102. d484 1
  1103. @
  1104.  
  1105.  
  1106. 1.13
  1107. log
  1108. @from conor nolan (missed changes)
  1109. @
  1110. text
  1111. @d13 1
  1112. a13 1
  1113.  * $Id: wvmail.c 1.12 1993/12/08 01:28:38 rushing Exp $
  1114. d15 3
  1115. d55 1
  1116. d96 7
  1117. a102 11
  1118.  
  1119.       WndMail->hWndEdit = CreateWindow ("edit", (char *) NULL,
  1120.               WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER
  1121.               | ES_LEFT | ES_MULTILINE |
  1122.               ES_AUTOHSCROLL | ES_AUTOVSCROLL
  1123.               ,
  1124.               0, 0, 0, 0,
  1125.               hWnd, EDITID, hInst, NULL);
  1126.  
  1127.      WndMail->dirty = DT_CLEAN ;
  1128.      CreatePostingText (MailDoc, hWnd, WndMail->hWndEdit, DOCTYPE_MAIL);
  1129. d108 1
  1130. d110 9
  1131. d163 1
  1132. a163 1
  1133.       StartMail (hWnd, ih);
  1134. d166 9
  1135. d183 1
  1136. a183 1
  1137.       WndMail->hWnd = 0;
  1138. d365 2
  1139. a366 3
  1140.  *
  1141.  *    Entry    ih    is the index into hWndMailEdits of the child
  1142.  *                   edit window containing the article.
  1143. d369 1
  1144. a369 3
  1145. StartMail (hWnd , ih)
  1146.     HWND hWnd ;
  1147.     int ih;
  1148. d373 1
  1149. a373 2
  1150.   HANDLE hEditBuffer;
  1151.   HWND hWndMailEdit = WndMails[ih].hWndEdit;
  1152. d375 4
  1153. a378 6
  1154.   hEditBuffer = (HANDLE) SendMessage (hWndMailEdit, EM_GETHANDLE, 0, 0L);
  1155.   editptr = LocalLock (hEditBuffer);
  1156.  
  1157.   MailOK=(MailCtrl.fnMlSend)(hWnd,editptr) ;
  1158.  
  1159.   LocalUnlock (hEditBuffer);
  1160. d458 1
  1161. a458 1
  1162.      if (MailLog) WriteEditLog(hWnd,MailLogFile,mBuf) ;
  1163. @
  1164.  
  1165.  
  1166. 1.12
  1167. log
  1168. @new version box and cr lf consistency
  1169. @
  1170. text
  1171. @d13 1
  1172. a13 1
  1173.  * $Id: wvmail.c 1.11 1993/08/25 18:54:36 mbretherton Exp rushing $
  1174. d15 3
  1175. d134 5
  1176. a138 3
  1177.  
  1178.     if (LOWORD(lParam) == WndMail->hWndEdit)
  1179.     {  // Edit Window notifications to parent
  1180. d140 1
  1181. d145 1
  1182. a145 1
  1183.       switch (wParam)
  1184. @
  1185.  
  1186.  
  1187. 1.11
  1188. log
  1189. @MRB merge, mail & post logging
  1190. @
  1191. text
  1192. @d11 1
  1193. d13 1
  1194. a13 1
  1195.  * $Id: wvmail.c 1.10 1993/06/29 00:22:35 rushing Exp $
  1196. d15 3
  1197. @
  1198.  
  1199.  
  1200. 1.10
  1201. log
  1202. @make smtp headers have Date: header
  1203. @
  1204. text
  1205. @d12 1
  1206. a12 1
  1207.  * $Id: wvmail.c 1.9 1993/06/28 17:51:39 rushing Exp rushing $
  1208. d14 3
  1209. d59 2
  1210. a60 2
  1211.   HWND hWndMailEdit;
  1212.   int ih, found;
  1213. d62 1
  1214. a62 5
  1215.   for (ih = 0, found = FALSE; !found && ih < MAXMAILWNDS; ih++)
  1216.     {
  1217.       if (hWndMails[ih] == hWnd)
  1218.     {
  1219.       hWndMailEdit = hWndMailEdits[ih];
  1220. d64 1
  1221. a64 5
  1222.       found = TRUE;
  1223.       break;
  1224.     }
  1225.     }
  1226.   if (!found && message == WM_CREATE)
  1227. d66 1
  1228. a66 1
  1229.       for (ih = 0; !found && ih < MAXVIEWS; ih++)
  1230. d68 1
  1231. a68 1
  1232.       if (!hWndMails[ih])
  1233. d70 4
  1234. a73 2
  1235.           found = TRUE;
  1236.           hWndMails[ih] = hWnd;
  1237. d86 1
  1238. a86 2
  1239.       hWndMailEdit = hWndMailEdits[ih] =
  1240.     CreateWindow ("edit", (char *) NULL,
  1241. d94 3
  1242. a96 2
  1243.       CreatePostingText (MailDoc, hWnd, hWndMailEdit, DOCTYPE_MAIL);
  1244.  
  1245. d98 1
  1246. a98 1
  1247.       SetWindowLong (hWndMailEdit,
  1248. d106 1
  1249. a106 1
  1250.      MoveWindow (hWndMailEdit, 0, 0, LOWORD (lParam),
  1251. d112 1
  1252. a112 1
  1253.       SetFocus (hWndMailEdit);
  1254. d118 1
  1255. a118 1
  1256.       NextWindow (&(MailDocs[ih]));
  1257. d123 1
  1258. a123 1
  1259.       prepareEditMenu (hWnd, hWndMailEdit);
  1260. d127 8
  1261. d139 1
  1262. a139 1
  1263.       DestroyWindow (hWnd);
  1264. d142 1
  1265. a142 1
  1266.     case IDM_POST:
  1267. d147 1
  1268. a147 1
  1269.       DoEditCommands (hWndMailEdit, wParam, lParam);
  1270. d154 2
  1271. a155 2
  1272.     hWndMails[ih] = 0;
  1273.     hWndMailEdits[ih] = 0;
  1274. d159 3
  1275. d202 1
  1276. a202 1
  1277.         if (strcmp(SMTPHost,""))
  1278. d205 2
  1279. a206 2
  1280.           MailCtrl.MailType = MT_SMTP;
  1281.         } else 
  1282. d292 1
  1283. a292 1
  1284.     MailCtrl.enableForward = MF_ENABLED ;    
  1285. d348 1
  1286. a348 1
  1287.   HWND hWndMailEdit = hWndMailEdits[ih];
  1288. d403 1
  1289. a403 1
  1290.  
  1291. d431 2
  1292. a432 1
  1293.   if (send_smtp_message (Addressee,mBuf)) {
  1294. d435 4
  1295. a438 2
  1296.       DestroyWindow(hWnd) ;
  1297.     return (TRUE);
  1298. @
  1299.  
  1300.  
  1301. 1.9
  1302. log
  1303. @fixed compiler warnings
  1304. @
  1305. text
  1306. @d12 1
  1307. a12 1
  1308.  * $Id: wvmail.c 1.8 1993/06/22 19:09:14 rushing Exp rushing $
  1309. d14 3
  1310. d261 1
  1311. a261 1
  1312. //        MakeArtHeaderDate,
  1313. @
  1314.  
  1315.  
  1316. 1.8
  1317. log
  1318. @mail force type selection via dialog
  1319. @
  1320. text
  1321. @d12 1
  1322. a12 1
  1323.  * $Id: wvmail.c 1.7 1993/06/22 16:45:51 bretherton Exp rushing $
  1324. d14 3
  1325. a54 2
  1326.   char mesbuf[348];        /*** debug */
  1327.  
  1328. a94 2
  1329. /*      SetWindowText (hWndMailEdits[ih], mesbuf); */
  1330.  
  1331. d98 3
  1332. a100 1
  1333.       SetWindowLong (hWndMailEdit, GWL_WNDPROC, lpfnEditSubClass);
  1334. d163 1
  1335. d167 1
  1336. a167 1
  1337.   (MailCtrl.fnMlClose)(hWnd) ;
  1338. d175 1
  1339. a175 2
  1340. MailInit (hWnd) 
  1341.     HWND hWnd;
  1342. d228 5
  1343. a232 18
  1344. MailDefCtlProc (hWnd) 
  1345.     HWND hWnd;
  1346. {  
  1347.    return (0);
  1348. }
  1349. MailDefChrProc (hWnd, mBuf) 
  1350.     HWND hWnd;
  1351.     char *mBuf;
  1352. {  
  1353.    return (0);
  1354. }
  1355. MailDefDocProc (hWnd, Doc, DocType) 
  1356.    HWND hWnd ;
  1357.    TypDoc *Doc;
  1358.    int DocType;
  1359. {  
  1360.    return (0);
  1361. }
  1362. d273 2
  1363. a274 4
  1364.     MailCtrl.fnMlSend=MailCtrl.fnMlForward=MailDefChrProc  ;
  1365.     MailCtrl.fnMlForward=MailDefDocProc;
  1366.             // Easy to do but best get ver 80 out the door
  1367.                     // M Bretherton 
  1368. d299 2
  1369. a300 2
  1370.     MailCtrl.fnMlSend=MailCtrl.fnMlForward=MailDefChrProc ;
  1371.     MailCtrl.fnMlForward=MailDefDocProc;
  1372. d434 1
  1373. a434 1
  1374.           (char far *) "Enter recipient's email address:");
  1375. @
  1376.  
  1377.  
  1378. 1.7
  1379. log
  1380. @*** empty log message ***
  1381. @
  1382. text
  1383. @d12 1
  1384. a12 1
  1385.  * $Id: wvmail.c 1.6 1993/06/11 00:11:26 rushing Exp $
  1386. d14 3
  1387. d178 1
  1388. a178 1
  1389.   if (MailForceType > 0)
  1390. @
  1391.  
  1392.  
  1393. 1.6
  1394. log
  1395. @second merge from Matt Bretherton sources
  1396. @
  1397. text
  1398. @d12 1
  1399. a12 1
  1400.  * $Id: wvmail.c 1.5 1993/05/19 23:49:08 rushing Exp rushing $
  1401. d14 6
  1402. a180 1
  1403.  
  1404. d186 6
  1405. a191 2
  1406.     }
  1407.       else
  1408. a195 3
  1409.   /* We assume that if they specify an SMTP host they want SMTP */
  1410.   if (strcmp(SMTPHost,""))
  1411.     MailCtrl.MailType = MT_SMTP;
  1412. d267 1
  1413. d278 1
  1414. d283 3
  1415. d291 2
  1416. a292 1
  1417.     MailCtrl.enableLogout = MF_GRAYED;    
  1418. d307 1
  1419. d311 1
  1420. d420 1
  1421. d432 3
  1422. a434 1
  1423.     MessageBox (hWnd, "Mail delivered to server", "WinVN", MB_OK);
  1424. @
  1425.  
  1426.  
  1427. 1.5
  1428. log
  1429. @notify user after succesfull forward_smtp_message
  1430. @
  1431. text
  1432. @d12 1
  1433. a12 1
  1434.  * $Id: wvmail.c 1.4 1993/05/18 22:10:45 rushing Exp rushing $
  1435. d14 3
  1436. d88 4
  1437. a91 1
  1438.       
  1439. d112 4
  1440. d128 2
  1441. a129 18
  1442.     case IDM_UNDO:
  1443.       SendMessage (hWndMailEdit, WM_UNDO, 0, 0L);
  1444.       break;
  1445.  
  1446.     case IDM_CUT:
  1447.       SendMessage (hWndMailEdit, WM_CUT, 0, 0L);
  1448.       break;
  1449.  
  1450.     case IDM_COPY:
  1451.       SendMessage (hWndMailEdit, WM_COPY, 0, 0L);
  1452.       break;
  1453.  
  1454.     case IDM_PASTE:
  1455.       SendMessage (hWndMailEdit, WM_PASTE, 0, 0L);
  1456.       break;
  1457.  
  1458.     case IDM_CLEAR:
  1459.       SendMessage (hWndMailEdit, WM_CLEAR, 0, 0L);
  1460. a130 5
  1461.  
  1462.     case IDM_SELALL:
  1463.       SendMessage (hWndMailEdit, EM_SETSEL, 0,
  1464.                MAKELONG (0, 32767));
  1465.       break;
  1466. d153 1
  1467. a153 1
  1468. MailLogout (hWnd) 
  1469. d156 1
  1470. a156 1
  1471.   (MailCtrl.fnMlLogout)(hWnd) ;
  1472. d169 6
  1473. a174 1
  1474.   Mapi_Type =  GetProfileInt("Mail","MAPI",0) ;
  1475. d176 1
  1476. a176 8
  1477.   if (Mapi_Type == 1)
  1478.   { 
  1479.      MailCtrl.MailType = MT_MAPI ;
  1480.   }
  1481.   else
  1482.   {
  1483.      MailCtrl.MailType = MT_NONE ;
  1484.   } ;
  1485. d178 9
  1486. d193 1
  1487. a193 5
  1488.   if ((MailCtrl.fnMlInit)(hWnd))
  1489.     {
  1490.       /* On failure to initialise mail interface disable said interface */ 
  1491.       SetMailType(MT_NONE)  ;
  1492.     } ;
  1493. d197 15
  1494. d242 2
  1495. a243 2
  1496. SetMailType (mailType)
  1497.   int mailType ;
  1498. a267 7
  1499.      case MT_NONE :
  1500.     MailCtrl.enableMail = MF_GRAYED ;
  1501.     MailCtrl.fnMlInit=MailCtrl.fnMlLogout=MailDefCtlProc ;
  1502.     MailCtrl.fnMlSend=MailCtrl.fnMlForward=MailDefChrProc ;
  1503.     MailCtrl.fnMlWinCreate=MailDefDocProc;
  1504.     MailCtrl.MailHeaderFuncs = NoHeaderFuncs ;
  1505.     break ;
  1506. d270 1
  1507. d273 1
  1508. d280 1
  1509. d282 2
  1510. a288 1
  1511.     
  1512. d291 10
  1513. d303 15
  1514. @
  1515.  
  1516.  
  1517. 1.4
  1518. log
  1519. @smtp support
  1520. @
  1521. text
  1522. @d12 1
  1523. a12 1
  1524.  * $Id: wvmail.c 1.3 1993/04/27 21:29:23 rushing Exp rushing $
  1525. d14 3
  1526. d401 2
  1527. a402 1
  1528.     if (forward_smtp_message (DialogString, Doc))
  1529. d404 1
  1530. @
  1531.  
  1532.  
  1533. 1.3
  1534. log
  1535. @added rcs log and id magikstrings
  1536. @
  1537. text
  1538. @d12 4
  1539. a15 2
  1540.  * $Id$
  1541.  * $Log$
  1542. d17 1
  1543. d25 2
  1544. d70 10
  1545. a79 10
  1546.      hWndMailEdit = hWndMailEdits[ih] = CreateWindow ("edit", (char *) NULL,
  1547.          WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_BORDER
  1548.                           | ES_LEFT | ES_MULTILINE |
  1549.                          ES_AUTOHSCROLL | ES_AUTOVSCROLL
  1550.                                ,
  1551.                                0, 0, 0, 0,
  1552.                          hWnd, EDITID, hInst, NULL);
  1553.       sprintf (mesbuf, "hWndMailEdits[%d] = %5d\r\n       ", ih, hWndMailEdits[ih]);
  1554.       /*   MessageBox(hWnd,mesbuf,"Edit Window Results",MB_OK|MB_ICONASTERISK); */
  1555.       SetWindowText (hWndMailEdits[ih], mesbuf);
  1556. d82 1
  1557. a82 1
  1558.       /*   SetFocus(hWndEdits[ih]);  */
  1559. d175 1
  1560. a175 1
  1561.   int Mapi_Type ;
  1562. d188 3
  1563. a190 7
  1564. /* mrb debug */
  1565.   if (Mapi_Type == 2)
  1566.   { 
  1567.      MailCtrl.MailType = MT_POP ;
  1568.   }
  1569. /* end mrb debug */
  1570.  
  1571. d245 1
  1572. a245 1
  1573.  static BOOL (*POPHeaderFuncs[])(TypDoc * Doc, char *Buf, long int BufLen) =
  1574. d251 1
  1575. d255 1
  1576. d261 1
  1577. a261 1
  1578.     MailCtrl.fnMlSend=MailDefChrProc ;
  1579. a263 1
  1580.  
  1581. d269 1
  1582. a269 1
  1583.     MailCtrl.fnMlSend=MailDefChrProc  ;
  1584. d271 1
  1585. a271 1
  1586.     MailCtrl.MailHeaderFuncs = MAPIHeaderFuncs ;
  1587. d273 1
  1588. a273 1
  1589.      case MT_POP :
  1590. d276 2
  1591. a277 1
  1592.     MailCtrl.fnMlSend=mlPOPSend ;
  1593. d279 5
  1594. a283 4
  1595.     MailCtrl.MailHeaderFuncs = POPHeaderFuncs  ;
  1596.     break ;
  1597.      /* error handling for Fall through case 
  1598.     message box plus default to none */
  1599. a303 1
  1600.  
  1601. a306 1
  1602.  
  1603. d336 2
  1604. a337 2
  1605.   char outline[MAXOUTLINE], cmdline[MAXOUTLINE];
  1606.   char  *outptr, *cptr;
  1607. d370 3
  1608. a372 6
  1609.  mlPOPSend (hWnd ,mBuf )
  1610.     HWND hWnd;
  1611.     char *mBuf;
  1612.  {
  1613.   BOOL found;
  1614.   BOOL MailOK = FALSE, got_To = FALSE, Addressed = FALSE;
  1615. a373 3
  1616.   char outline[MAXOUTLINE], cmdline[MAXOUTLINE];
  1617.   char  *outptr, *cptr;
  1618.   int linelen;
  1619. d375 1
  1620. a375 1
  1621.     MessageBox (hWnd, "POP Send", "Debug!", MB_OK | MB_ICONHAND);
  1622. d377 1
  1623. a377 11
  1624.     Addressed=GetMailHeaderString (mBuf, "To: ", Addressee, MAXOUTLINE) ;
  1625.  
  1626.      if (!Addressed)
  1627.     {
  1628.       MessageBox (hWnd, "Fill in the \"To:\" line", "Need a recipient",
  1629.               MB_OK | MB_ICONHAND);
  1630.           return(FALSE) ; 
  1631.     }
  1632.  
  1633.                                           
  1634.   if (CommBusy)
  1635. d379 3
  1636. a381 2
  1637.       MessageBox (hWndMails[ih], "Sorry, I am already busy retrieving information from the server.\n\
  1638. Try again in a little while.", "Can't mail message right now", MB_OK | MB_ICONASTERISK);
  1639. d383 5
  1640. d389 2
  1641. a390 31
  1642.     {
  1643.       CommLinePtr = CommLineIn;
  1644.       CommBusy = TRUE;
  1645.       CommState = ST_MAIL_WAIT_PERMISSION;
  1646.       CommDoc = &(MailDocs[ih]);
  1647.  
  1648.       /* Create XMAIL command.  We need to extract the "To:" line
  1649.        * in order to find the recipient for the command.
  1650.        */
  1651.  
  1652.  
  1653.    strcpy (cmdline, "xMail ");
  1654.    outptr = Addressee ;
  1655.    for (cptr = cmdline + strlen (cmdline);
  1656.      *outptr > ' ' && cptr - cmdline < MAXOUTLINE;
  1657.      *(cptr++) = *(outptr++));
  1658.    *cptr++ = '\r' ;
  1659.    *cptr++ = '\n' ;
  1660.    *cptr = '\0';
  1661.    outptr = mBuf  ;
  1662.    for (cptr = cmdline + strlen (cmdline);
  1663.         cptr - cmdline < MAXOUTLINE;
  1664.      *(cptr++) = *(outptr++));
  1665.    *cptr = '\0';
  1666.  
  1667.   MessageBox (hWnd, cmdline, "XMail Message", MB_OK | MB_ICONHAND);
  1668. /*   This is silly ->
  1669.    Originally only put out the header
  1670.    But on my chnage only puts out a limited number of characters
  1671.    Should be line by line
  1672.               mrb */
  1673. d392 2
  1674. a393 2
  1675.    PutCommLine (cmdline, strlen (cmdline));
  1676.    MailOK = TRUE;
  1677. d395 13
  1678. a407 4
  1679.     } 
  1680.  
  1681. return(MailOK) ;
  1682.  }
  1683. @
  1684.  
  1685.  
  1686. 1.2
  1687. log
  1688. @MAPI
  1689. @
  1690. text
  1691. @d11 6
  1692. @
  1693.  
  1694.  
  1695. 1.1
  1696. log
  1697. @Initial revision
  1698. @
  1699. text
  1700. @a0 7
  1701. /*
  1702.  *
  1703.  * $Id$
  1704.  * $Log$
  1705.  *
  1706.  */
  1707.  
  1708. d7 2
  1709. a23 1
  1710.  
  1711. d28 1
  1712. d33 1
  1713. a34 1
  1714.       hWndMailEdit = hWndMailEdits[ih];
  1715. d59 1
  1716. a59 1
  1717.       hWndMailEdit = hWndMailEdits[ih] = CreateWindow ("edit", (char *) NULL,
  1718. d76 1
  1719. a76 1
  1720.       MoveWindow (hWndMailEdit, 0, 0, LOWORD (lParam),
  1721. a91 1
  1722.  
  1723. d101 1
  1724. a101 1
  1725.       StartMail (ih);
  1726. d133 2
  1727. a134 3
  1728.       hWndMails[ih] = 0;
  1729.  
  1730.       hWndMailEdits[ih] = 0;
  1731. d145 131
  1732. d285 3
  1733. a287 2
  1734. StartMail (ih)
  1735.      int ih;
  1736. d289 2
  1737. a290 3
  1738.   BOOL MailOK = FALSE, got_To = FALSE;
  1739.   char outline[MAXOUTLINE], cmdline[MAXOUTLINE];
  1740.   char *editptr, *outptr, *cptr;
  1741. d293 78
  1742. d373 12
  1743. d401 24
  1744. a424 2
  1745.       hEditBuffer = (HANDLE) SendMessage (hWndMailEdit, EM_GETHANDLE, 0, 0L);
  1746.       editptr = LocalLock (hEditBuffer);
  1747. d426 1
  1748. a426 12
  1749.       while (!got_To && *editptr)
  1750.     {
  1751.       for (linelen = 0, outptr = outline; *editptr && *editptr != '\r' &&
  1752.            linelen < MAXOUTLINE; linelen++)
  1753.         *(outptr++) = *(editptr++);
  1754.       *outptr = '\0';
  1755.       if (CompareStringNoCase (outline, "To: ", 4) == 0)
  1756.         {
  1757.           got_To = TRUE;
  1758.         }
  1759.     }
  1760.       LocalUnlock (hEditBuffer);
  1761. d428 2
  1762. a429 20
  1763.       if (!got_To)
  1764.     {
  1765.       MessageBox (hWndMails[ih], "Fill in the \"To:\" line", "Need a recipient",
  1766.               MB_OK | MB_ICONHAND);
  1767.     }
  1768.       else
  1769.     {
  1770.       outptr = outline;
  1771.       NextToken (&outptr);
  1772.       strcpy (cmdline, "xMail ");
  1773.       for (cptr = cmdline + strlen (cmdline);
  1774.            *outptr > ' ' && cptr - cmdline < MAXOUTLINE;
  1775.            *(cptr++) = *(outptr++));
  1776.       *cptr = '\0';
  1777.       PutCommLine (cmdline, strlen (cmdline));
  1778.       MailOK = TRUE;
  1779.     }
  1780.     }
  1781.   return (MailOK);
  1782. }
  1783. @
  1784.