(file) Return to EmailListenerDestination.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Handler / EmailListenerDestination

Diff for /pegasus/src/Pegasus/Handler/EmailListenerDestination/EmailListenerDestination.cpp between version 1.6.2.1 and 1.7

version 1.6.2.1, 2006/10/27 18:27:18 version 1.7, 2006/08/15 17:24:21
Line 44 
Line 44 
 #include <Pegasus/Common/IndicationFormatter.h> #include <Pegasus/Common/IndicationFormatter.h>
 #include <Pegasus/IndicationService/IndicationConstants.h> #include <Pegasus/IndicationService/IndicationConstants.h>
  
 #if defined(PEGASUS_OS_VMS)  #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_OS_LINUX)
 #include <unistd>  
 #include <stdio>  
 #include <descrip>  
 #include <ssdef>  
 #include <maildef>  
 #include <mail$routines>  
 #include <nam>  
 #include <starlet>  
 #endif  
   
 #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_OS_LINUX) && \  
     !defined(PEGASUS_OS_VMS)  
 # error "Unsupported Platform" # error "Unsupported Platform"
 #endif #endif
  
Line 163 
Line 151 
     PEG_METHOD_ENTER (TRC_IND_HANDLER,     PEG_METHOD_ENTER (TRC_IND_HANDLER,
         "EmailListenerDestination::_sendViaEmail");         "EmailListenerDestination::_sendViaEmail");
  
 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || \  #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX)
     defined(PEGASUS_OS_VMS)  
  
     String exceptionStr;     String exceptionStr;
     FILE * mailFilePtr;     FILE * mailFilePtr;
     FILE * filePtr;     FILE * filePtr;
     char mailFile[TEMP_NAME_LEN];     char mailFile[TEMP_NAME_LEN];
  
 #ifndef PEGASUS_OS_VMS  
     // Check for proper execute permissions for sendmail     // Check for proper execute permissions for sendmail
     if (access(SENDMAIL_CMD, X_OK) < 0)     if (access(SENDMAIL_CMD, X_OK) < 0)
     {     {
Line 194 
Line 180 
  
         return;         return;
     }     }
 #endif  
  
     // open a temporary file to hold the indication mail message     // open a temporary file to hold the indication mail message
     _openFile(&filePtr, mailFile);     _openFile(&filePtr, mailFile);
Line 220 
Line 205 
  
     try     try
     {     {
 #ifdef PEGASUS_OS_VMS  
     //  
     // Start mail send process  
     //  
     status = mail$send_begin(&send_context, &nulllist, &nulllist);  
     if (status != SS$_NORMAL)  
     {  
       PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,  
                      "Routine mail$send_begin failed.");  
       PEG_METHOD_EXIT();  
   
       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                    MessageLoaderParms("Handler.EmailListenerDestination."  
        "EmailListenerDestination.ROUTINE_MAIL_SEND_BEGIN_FAILED.PEGASUS_OS_VMS",  
                             "Routine mail$send_begin failed."));  
     }  
 #endif  
         // send the message         // send the message
         _sendMsg(mailFile);         _sendMsg(mailFile);
     }     }
Line 289 
Line 257 
             "Do not have an e-mail address."));             "Do not have an e-mail address."));
     }     }
  
 #ifdef PEGASUS_OS_VMS  
   
   //  
   // Add cc destination to message.  
   //  
   
   String mailCcStr = _buildMailAddrCcStr(mailCc);  
   
   //  
   // Write the mailSubject string  
   //  
   
   String mailSubjectStr = String::EMPTY;  
   mailSubjectStr.append(mailSubject);  
   CString foo = mailSubjectStr.getCString();  
   
   attribute_itmlst[0].buffer_length = strlen(foo);  
   attribute_itmlst[0].buffer_address = (long &)foo;  
   
   status = mail$send_add_attribute(&send_context, attribute_itmlst, &nulllist);  
   if (status != SS$_NORMAL)  
   {  
     PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,  
                      "Routine mail$send_add_attribute failed.");  
     PEG_METHOD_EXIT();  
   
     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                    MessageLoaderParms("Handler.EmailListenerDestination."  
        "EmailListenerDestination.ROUTINE_MAIL_SEND_ADD_ATTRIBUTE_FAILED.PEGASUS_OS_VMS",  
                             "Routine mail$send_add_attribute failed."));  
   }  
   
   //  
   // Add filename to bodypart of the message  
   //  
   
   bodypart_itmlst[0].buffer_length = strlen(mailFileVms);  
   bodypart_itmlst[0].buffer_address = (long &)mailFileVms;  
   
   status = mail$send_add_bodypart(&send_context, bodypart_itmlst, 0);  
   if (status != SS$_NORMAL)  
   {  
     PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,  
                      "Routine mail$send_add_bodypart failed..");  
     PEG_METHOD_EXIT();  
   
     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                    MessageLoaderParms("Handler.EmailListenerDestination."  
        "EmailListenerDestination.ROUTINE_MAIL_SEND_ADD_BODYPART_FAILED.PEGASUS_OS_VMS",  
                             "Routine mail$send_add_bodypart failed."));  
   }  
   
 #else  
   
     String mailHdrStr = String::EMPTY;     String mailHdrStr = String::EMPTY;
  
     // Write the mailToStr to file     // Write the mailToStr to file
Line 374 
Line 288 
     mailSubjectStr.append("Subject: ");     mailSubjectStr.append("Subject: ");
     mailSubjectStr.append(mailSubject);     mailSubjectStr.append(mailSubject);
     _writeStrToFile(mailSubjectStr, filePtr);     _writeStrToFile(mailSubjectStr, filePtr);
 #endif  
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
Line 390 
Line 303 
  
     for (Uint32 i=0; i < mailAddrSize; i++)     for (Uint32 i=0; i < mailAddrSize; i++)
     {     {
 #if defined(PEGASUS_OS_VMS)  
   
     CString mailAddrVms = mailAddr[i].getCString();  
     //  
     // Add destination to message  
     //  
     address_itmlst[0].buffer_length = strlen(mailAddrVms);  
     address_itmlst[0].buffer_address = (long &)mailAddrVms;  
   
     status = mail$send_add_address(&send_context, address_itmlst, &nulllist);  
     if (status != SS$_NORMAL)  
     {  
       PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,  
                      "Routine mail$send_add_address failed.");  
       PEG_METHOD_EXIT();  
   
       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                    MessageLoaderParms("Handler.EmailListenerDestination."  
        "EmailListenerDestination.ROUTINE_MAIL_SEND_ADD_ADDRESS_FAILED.PEGASUS_OS_VMS",  
                             "Routine mail$send_add_address failed."));  
     }  
     mailAddrStr = "VMS";  
 #else  
         mailAddrStr.append(mailAddr[i]);         mailAddrStr.append(mailAddr[i]);
  
         if (i < (mailAddrSize - 1))         if (i < (mailAddrSize - 1))
         {         {
             mailAddrStr.append(",");             mailAddrStr.append(",");
         }         }
 #endif  
     }  
   
     PEG_METHOD_EXIT();  
     return (mailAddrStr);  
 }  
   
 #ifdef PEGASUS_OS_VMS  
 String EmailListenerDestination::_buildMailAddrCcStr(  
                                         const Array < String > &mailAddr)  
 {  
   PEG_METHOD_ENTER(TRC_IND_HANDLER,  
                    "EmailListenerDestination::_buildMailAddrCcStr");  
   
   String mailAddrStr = String::EMPTY;  
   Uint32 mailAddrSize = mailAddr.size();  
   
   for (Uint32 i = 0; i < mailAddrSize; i++)  
   {  
     CString mailAddrCcVms = mailAddr[i].getCString();  
     //  
     // Add cc destination to message  
     //  
     address_cc_itmlst[0].buffer_length = strlen(mailAddrCcVms);  
     address_cc_itmlst[0].buffer_address = (long &)mailAddrCcVms;  
   
     status = mail$send_add_address(&send_context, address_cc_itmlst, &nulllist);  
     if (status != SS$_NORMAL)  
     {  
       PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,  
                      "Routine mail$send_add_address failed (cc).");  
       PEG_METHOD_EXIT();  
   
       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                    MessageLoaderParms("Handler.EmailListenerDestination."  
        "EmailListenerDestination.ROUTINE_MAIL_SEND_ADD_ADDRESS_FAILED_CC.PEGASUS_OS_VMS",  
                             "Routine mail$send_add_address failed (cc)."));  
     }  
   }   }
  
   PEG_METHOD_EXIT();   PEG_METHOD_EXIT();
   return (mailAddrStr);   return (mailAddrStr);
 } }
  
 #endif  
   
 void EmailListenerDestination::_writeStrToFile( void EmailListenerDestination::_writeStrToFile(
     const String & mailHdrStr,     const String & mailHdrStr,
     FILE * filePtr)     FILE * filePtr)
Line 569 
Line 419 
         throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);         throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);
     }     }
  
 #ifdef PEGASUS_OS_VMS  
   //  
   // Send the mail message  
   //  
   status = mail$send_message(&send_context, nulllist, nulllist);  
   if (status != SS$_NORMAL)  
   {  
     PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,  
                      "Routine mail$send_message failed.");  
     PEG_METHOD_EXIT();  
   
     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                    MessageLoaderParms("Handler.EmailListenerDestination."  
        "EmailListenerDestination.ROUTINE_MAIL_SEND_MESSAGE_FAILED.PEGASUS_OS_VMS",  
                             "Routine mail$send_message failed."));  
   }  
   
   //  
   // End mail send process  
   //  
   status = mail$send_end(&send_context, nulllist, nulllist);  
   if (status != SS$_NORMAL)  
   {  
     PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,  
                      "Routine mail$send_end failed.");  
     PEG_METHOD_EXIT();  
   
     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                    MessageLoaderParms("Handler.EmailListenerDestination."  
        "EmailListenerDestination.ROUTINE_MAIL_SEND_END_FAILED.PEGASUS_OS_VMS",  
                             "Routine mail$send_end failed."));  
   }  
   
 #else  
   
     sprintf(sendmailCmd, "%s %s %s", SENDMAIL_CMD,     sprintf(sendmailCmd, "%s %s %s", SENDMAIL_CMD,
             SENDMAIL_CMD_OPTS, mailFile);             SENDMAIL_CMD_OPTS, mailFile);
  
Line 657 
Line 472 
  
         throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);         throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);
     }     }
 #endif  
   
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
Line 672 
Line 485 
     String exceptionStr;     String exceptionStr;
  
     *filePtr = fopen(tmpnam(mailFile), "w");     *filePtr = fopen(tmpnam(mailFile), "w");
 #ifdef PEGASUS_OS_VMS  
   strcpy(mailFileVms, mailFile);  
 #endif  
     if (*filePtr == NULL)     if (*filePtr == NULL)
     {     {
         Tracer::trace(TRC_IND_HANDLER, Tracer::LEVEL4,         Tracer::trace(TRC_IND_HANDLER, Tracer::LEVEL4,
Line 697 
Line 507 
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 // This is the dynamic entry point into this dynamic module. The name of  PEGASUS_NAMESPACE_END
 // this handler is "EmailListenerDestination" which is appended to "PegasusCreateHandler_"  
 // to form a symbol name. This function is called by the HandlerTable  
 // to load this handler.  
  
 extern "C" PEGASUS_EXPORT CIMHandler*  PEGASUS_USING_PEGASUS;
     PegasusCreateHandler_EmailListenerDestination() {  
   // This is the entry point into this dynamic module.
   
   extern "C" PEGASUS_EXPORT CIMHandler* PegasusCreateHandler(
       const String& handlerName)
   {
       if (handlerName == "EmailListenerDestination")
       {
     return new EmailListenerDestination;     return new EmailListenerDestination;
 } }
  
 PEGASUS_NAMESPACE_END      return 0;
   }


Legend:
Removed from v.1.6.2.1  
changed lines
  Added in v.1.7

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2