(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 and 1.6.2.1

version 1.6, 2006/01/30 16:17:51 version 1.6.2.1, 2006/10/27 18:27:18
Line 29 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Yi Zhou, Hewlett-Packard Company (yi.zhou@hp.com)  
 //  
 // Modified By:  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
Line 48 
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_HPUX) && !defined(PEGASUS_OS_LINUX)  #if defined(PEGASUS_OS_VMS)
   #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 155 
Line 163 
     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 184 
Line 194 
  
         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 209 
Line 220 
  
     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 261 
Line 289 
             "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 292 
Line 374 
     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 307 
Line 390 
  
     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();     PEG_METHOD_EXIT();
     return (mailAddrStr);     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();
     return (mailAddrStr);
   }
   
   #endif
   
 void EmailListenerDestination::_writeStrToFile( void EmailListenerDestination::_writeStrToFile(
     const String & mailHdrStr,     const String & mailHdrStr,
     FILE * filePtr)     FILE * filePtr)
Line 423 
Line 569 
         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 476 
Line 657 
  
         throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);         throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, exceptionStr);
     }     }
   #endif
   
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
Line 489 
Line 672 
     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,


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2