⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pop3_protocol_class_wrapper.shtml.htm

📁 随书类文件![随书类]MFC_SOURCEBOOK
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">BOOL CPop::Statistics()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;char buf [512];</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">&nbsp;wsprintf (buf, "STAT \r\n");</FONT>
<BR><FONT COLOR="#990000">&nbsp;m_PopServer.Send(buf, strlen (buf));</FONT>
<BR><FONT COLOR="#990000">&nbsp;if (CheckResponse(STAT_CHECK)==FALSE)</FONT>
<BR><FONT COLOR="#990000">&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;else</FONT>
<BR><FONT COLOR="#990000">&nbsp; return TRUE;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">CString CPop::GetMsgContents()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;return m_MsgContents;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">int CPop::GetNumberOfMails()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;return m_NumberMail;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">int CPop::GetTotalMailSize()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;return m_TotalSize;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">BOOL CPop::Connect()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;Connect(m_Host, m_User, m_Password);</FONT>
<BR><FONT COLOR="#990000">&nbsp;return TRUE;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">void CPop::SetHost(CString &amp; Host)</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;m_Host = Host;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">CString CPop::GetHost()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;return m_Host;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">void CPop::SetUser(CString &amp; User)</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;m_User = User;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">CString CPop::GetUser()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;return m_User;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">void CPop::SetPassword(CString &amp; Password)</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;m_Password = Password;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">CString CPop::GetPassword()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;return m_Password;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">BOOL CPop::CheckResponse(int ResponseType)</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;char buf [1000];</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">&nbsp;for (int i=0;i&lt;512;i++)</FONT>
<BR><FONT COLOR="#990000">&nbsp; buf[i]='\0';</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">&nbsp;m_PopServer.Receive(buf, sizeof(buf));</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">&nbsp;switch (ResponseType)</FONT>
<BR><FONT COLOR="#990000">&nbsp;{</FONT>
<BR><FONT COLOR="#990000">&nbsp; case CONNECTION_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Bad Connection");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">&nbsp; case USER_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Bad User
Name");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT>
<BR><FONT COLOR="#990000">&nbsp; case PASSWORD_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Bad Password
Name");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT>
<BR><FONT COLOR="#990000">&nbsp; case QUIT_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Error
occured during QUIT");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT>
<BR><FONT COLOR="#990000">&nbsp; case DELETE_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Error
occured during DELE");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT>
<BR><FONT COLOR="#990000">&nbsp; case RSET_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Error
occured during RSET");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT>
<BR><FONT COLOR="#990000">&nbsp; case STAT_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Error
occured during STAT");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; else</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; BOOL EmailNumber = TRUE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; for (char *p = buf; *p !=
'\0'; p++)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp; if (*p == '\t' || *p
== ' ')</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(EmailNumber
== TRUE)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_NumberMail
= atoi(p);</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EmailNumber
= FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_TotalSize
= atoi(p);</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return TRUE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; }</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT>
<BR><FONT COLOR="#990000">&nbsp; case NOOP_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Error
occured during NOOP");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">&nbsp; case LIST_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Error
occured during LIST");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; else</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_PopServer.Receive(buf, sizeof(buf));</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; for (char *p = buf; *p != '.';
p++)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp; if (*p == '\t' || *p
== ' ')</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_SizeOfMsg.Add(atoi(p));</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT>
<BR><FONT COLOR="#990000">&nbsp; case RETR_CHECK:</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; if (strnicmp(buf,"-ERR", 4) == 0)</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_ErrorMessage = _T("Error
occured during RETR");</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; else</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; {</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; char temp[9000];</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_PopServer.Receive(temp,
sizeof(temp));</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp;&nbsp; m_MsgContents = temp;</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; }</FONT>
<BR><FONT COLOR="#990000">&nbsp;&nbsp; break;</FONT>
<BR><FONT COLOR="#990000">&nbsp;}</FONT>
<BR><FONT COLOR="#990000">&nbsp;return TRUE;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">CString CPop::GetErrorMessage()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;return m_ErrorMessage;</FONT>
<BR><FONT COLOR="#990000">}</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">BOOL CPop::List()</FONT>
<BR><FONT COLOR="#990000">{</FONT>
<BR><FONT COLOR="#990000">&nbsp;char buf [512];</FONT><FONT COLOR="#990000"></FONT>

<P><FONT COLOR="#990000">&nbsp;wsprintf (buf, "LIST&nbsp; \r\n");</FONT>
<BR><FONT COLOR="#990000">&nbsp;m_PopServer.Send(buf, strlen (buf));</FONT>
<BR><FONT COLOR="#990000">&nbsp;if (CheckResponse(LIST_CHECK)==FALSE)</FONT>
<BR><FONT COLOR="#990000">&nbsp; return FALSE;</FONT>
<BR><FONT COLOR="#990000">&nbsp;else</FONT>
<BR><FONT COLOR="#990000">&nbsp; return TRUE;</FONT>
<BR><FONT COLOR="#990000">}</FONT>
<BR><FONT COLOR="#990000"></FONT>&nbsp;
<BR><FONT COLOR="#990000"></FONT>&nbsp;
<BR><FONT COLOR="#990000"></FONT>&nbsp;<FONT COLOR="#990000"></FONT>








<P>
<HR>
<TABLE BORDER=0 WIDTH="100%" >
<TR>
<TD WIDTH="33%"><FONT SIZE=-1><A HREF="../index.htm" tppabs="http://www.codeguru.com/">Goto HomePage</A></FONT></TD>

<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>&copy; 1997 Zafir Anjum</FONT>&nbsp;</CENTER>
</TD>

<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A>&nbsp;</FONT></DIV>
</TD>
</TR>
</TABLE>
<CENTER><IMG SRC="../cgi/Count.cgi-ft=2&dd=E-df=bmp_emboss.cnt" tppabs="http://www.codeguru.com/cgi/Count.cgi?ft=2&dd=E%7cdf=bmp_emboss.cnt" ALIGN="BOTTOM" BORDER="0"></CENTER>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -