// groups.cpp : Implementation of CsmtpadmApp and DLL registration. #include "stdafx.h" #include "smtpadm.h" #include "alias.h" #include "oleutil.h" #include "smtpapi.h" #include #include "smtpcmn.h" // Must define THIS_FILE_* macros to use SmtpCreateException() #define THIS_FILE_HELP_CONTEXT 0 #define THIS_FILE_PROG_ID _T("Smtpadm.Alias.1") #define THIS_FILE_IID IID_ISmtpAdminAlias #define DEFAULT_NEWSGROUP_NAME _T("") #define DEFAULT_NEWSGROUP_DESCRIPTION _T("") #define DEFAULT_NEWSGROUP_MODERATOR _T("") #define DEFAULT_NEWSGROUP_READONLY FALSE ///////////////////////////////////////////////////////////////////////////// // // // Use a macro to define all the default methods // DECLARE_METHOD_IMPLEMENTATION_FOR_STANDARD_EXTENSION_INTERFACES(SmtpAdminAlias, CSmtpAdminAlias, IID_ISmtpAdminAlias) STDMETHODIMP CSmtpAdminAlias::InterfaceSupportsErrorInfo(REFIID riid) { static const IID* arr[] = { &IID_ISmtpAdminAlias, }; for (int i=0;icEntries; Exit: TraceFunctLeave (); return hr; } STDMETHODIMP CSmtpAdminAlias::GetNth( long lIndex ) { _ASSERT( lIndex >=0 && lIndex < m_lCount ); WCHAR* pchStartOfDomain = NULL; WCHAR* p = NULL; LPSMTP_NAME_ENTRY pNameEntry; if( !m_pSmtpNameList ) { return SmtpCreateException (IDS_SMTPEXCEPTION_DIDNT_ENUMERATE); } if( lIndex < 0 || lIndex >= m_lCount ) { return SmtpCreateException (IDS_SMTPEXCEPTION_INVALID_INDEX); } //_ASSERT( CAddr::ValidateEmailName(m_pSmtpNameList[lIndex].lpszName) ); pNameEntry = &m_pSmtpNameList->aNameEntry[lIndex]; p = pNameEntry->lpszName; while( *p && *p != '@' ) p++; _ASSERT( *p ); if( !*p ) { return SmtpCreateException (IDS_SMTPEXCEPTION_INVALID_ADDRESS); } pchStartOfDomain = p+1; m_lType = pNameEntry->dwType; m_strDomain = (LPCWSTR) pchStartOfDomain; *(pchStartOfDomain-1) = '\0'; m_strEmailId = pNameEntry->lpszName; // converted to UNICODE *(pchStartOfDomain-1) = '@'; // turn it back return NOERROR; }