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

  1 martin 1.8 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.9 //
  3 martin 1.8 // Licensed to The Open Group (TOG) under one or more contributor license
  4            // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5            // this work for additional information regarding copyright ownership.
  6            // Each contributor licenses this file to you under the OpenPegasus Open
  7            // Source License; you may not use this file except in compliance with the
  8            // License.
  9 martin 1.9 //
 10 martin 1.8 // Permission is hereby granted, free of charge, to any person obtaining a
 11            // copy of this software and associated documentation files (the "Software"),
 12            // to deal in the Software without restriction, including without limitation
 13            // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14            // and/or sell copies of the Software, and to permit persons to whom the
 15            // Software is furnished to do so, subject to the following conditions:
 16 martin 1.9 //
 17 martin 1.8 // The above copyright notice and this permission notice shall be included
 18            // in all copies or substantial portions of the Software.
 19 martin 1.9 //
 20 martin 1.8 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.9 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.8 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23            // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24            // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25            // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26            // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.9 //
 28 martin 1.8 //////////////////////////////////////////////////////////////////////////
 29 yi.zhou 1.1 //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             PEGASUS_NAMESPACE_BEGIN
 33             
 34             PEGASUS_USING_STD;
 35             
 36             #if defined(PEGASUS_OS_HPUX) || \
 37                 defined(PEGASUS_OS_LINUX)
 38 yi.zhou 1.2 # define SENDMAIL_CMD "/usr/sbin/sendmail"
 39             # define SENDMAIL_CMD_OPTS "-t -i <"
 40             # define TEMP_MAIL_FILE "tmpMailFile"
 41             # define MAX_SENDMAIL_CMD_LEN 100
 42             # define SH_EXECUTE_FAILED 127
 43             # define TEMP_NAME_LEN L_tmpnam
 44             # include <unistd.h>
 45 yi.zhou 1.1 #endif
 46 carson.hovey 1.6 #if defined(PEGASUS_OS_VMS)
 47                  # define MAX_SENDMAIL_CMD_LEN 100
 48                  # define TEMP_NAME_LEN L_tmpnam
 49                  
 50 kumpf        1.7 char mailFileVms[TEMP_NAME_LEN];
 51 carson.hovey 1.6 
 52 kumpf        1.7 long file_len = 0;
 53                  long subject_line_len = 0;
 54                  long to_user_len = 0;
 55                  
 56                  int send_context = 0;
 57                  int status = SS$_NORMAL;
 58 carson.hovey 1.6 
 59                  typedef struct itmlst
 60                  {
 61 kumpf        1.7     short buffer_length;
 62                      short item_code;
 63                      long buffer_address;
 64                      long return_length_address;
 65                  } ITMLST;
 66                  
 67                  ITMLST nulllist[] =
 68                  {
 69 kumpf        1.10     {0, 0, 0, 0}
 70 kumpf        1.7  };
 71                   
 72                   ITMLST address_itmlst[] =
 73                   {
 74                       {0, MAIL$_SEND_USERNAME, 0, 0},
 75                       {0, MAIL$_SEND_USERNAME_TYPE, MAIL$_TO, 0},
 76                       {0, 0, 0, 0}
 77                   };
 78                   
 79                   ITMLST address_cc_itmlst[] =
 80                   {
 81                       {0, MAIL$_SEND_USERNAME, 0, 0},
 82                       {0, MAIL$_SEND_USERNAME_TYPE, MAIL$_CC, 0},
 83                       {0, 0, 0, 0}
 84                   };
 85                   
 86                   ITMLST bodypart_itmlst[] =
 87                   {
 88                       {0, MAIL$_SEND_FILENAME, 0, 0},
 89                       {0, 0, 0, 0}
 90                   };
 91 kumpf        1.7  
 92                   ITMLST attribute_itmlst[] =
 93                   {
 94                       {0, MAIL$_SEND_SUBJECT, 0, 0},
 95                       {0, 0, 0, 0}
 96                   };
 97 carson.hovey 1.6  
 98                   #endif
 99 yi.zhou      1.1  
100                   class PEGASUS_HANDLER_LINKAGE EmailListenerDestination: public CIMHandler
101                   {
102                   public:
103                   
104                       EmailListenerDestination()
105                       {
106                       }
107                   
108                       virtual ~EmailListenerDestination()
109                       {
110                       }
111                   
112                       void initialize(CIMRepository* repository);
113                   
114                       void terminate()
115                       {
116                       }
117                   
118                       void handleIndication(
119 kumpf        1.7          const OperationContext& context,
120                           const String nameSpace,
121 kumpf        1.10         CIMInstance& indication,
122                           CIMInstance& handler,
123                           CIMInstance& subscription,
124 kumpf        1.7          ContentLanguageList& contentLanguages);
125 yi.zhou      1.1  
126                   private:
127                   
128                       /**
129 kumpf        1.10         Sends the formatted indication to the specified recipients.
130                           Utility "sendmail" is the default tool to be used. The platform
131 kumpf        1.7          maintainer can also choose different tools.
132 yi.zhou      1.1  
133 kumpf        1.10         @param  mailTo         the addresses of the To: field
134                           @param  mailCc         the addresses of the Cc: field
135                           @param  mailSubject    the Subject: field of the mail message
136                           @param  formattedText  the formatted indication
137 yi.zhou      1.1      */
138                   
139                       void _sendViaEmail(
140 kumpf        1.7          const Array<String>& mailTo,
141                           const Array<String>& mailCc,
142                           const String& mailSubject,
143                           const String& formattedText);
144 yi.zhou      1.1  
145                       /**
146                           Build the header of the mail message which includes To:, Cc:,
147 kumpf        1.7          From:, and Subject: fields
148 yi.zhou      1.1  
149 kumpf        1.10         @param  mailTo         the addresses of the To: field
150                           @param  mailCc         the addresses of the Cc: field
151                           @param  mailSubject    the Subject: field of the mail message
152                           @param  filePtr        the pointer to the temporary file
153 yi.zhou      1.1      */
154                   
155                       void _buildMailHeader(
156 kumpf        1.7          const Array<String>& mailTo,
157                           const Array<String>& mailCc,
158                           const String& mailSubject,
159                           FILE* filePtr);
160 yi.zhou      1.1  
161                       /**
162 kumpf        1.10         Build the mail address string from address array
163 yi.zhou      1.1  
164 kumpf        1.10         @param  mailAddr       the array of the mail addresses
165 yi.zhou      1.1  
166 kumpf        1.10         @return the string of the mail addresses
167 yi.zhou      1.1      */
168                       String _buildMailAddrStr(
169 kumpf        1.7          const Array<String>& mailAddr);
170 yi.zhou      1.1  
171 carson.hovey 1.6  #ifdef PEGASUS_OS_VMS
172                       /**
173 kumpf        1.10         Build the mail cc address string from address array
174 carson.hovey 1.6  
175 kumpf        1.10         @param  mailAddr       the array of the mail cc addresses
176 carson.hovey 1.6  
177 kumpf        1.10         @return the string of the mail addresses
178 carson.hovey 1.6      */
179                       String _buildMailAddrCcStr(
180 kumpf        1.7          const Array<String>& mailAddr);
181 carson.hovey 1.6  
182                   #endif
183 yi.zhou      1.1      /**
184 kumpf        1.10         Write the mail header string to file
185 yi.zhou      1.1  
186                           @param  mailHdrStr     the header string to be written to the file
187 kumpf        1.10         @param  filePtr        the pointer to the temporary file
188 yi.zhou      1.1      */
189                       void _writeStrToFile(
190 kumpf        1.7          const String& mailHdrStr,
191                           FILE* filePtr);
192 yi.zhou      1.1  
193                       /**
194 kumpf        1.10         Sends the indication via e-mail by opening a pipe to sendmail()
195 yi.zhou      1.3  
196 kumpf        1.10         @param  mailFile       The temporary file name
197 yi.zhou      1.1      */
198 kumpf        1.7      void _sendMsg(char* mailFile);
199 yi.zhou      1.3  
200                       /**
201 kumpf        1.7          Opens a temporary file to hold the indication mail message
202 yi.zhou      1.1  
203 kumpf        1.10         @param  filePtr     the address of the pointer to the open file
204                           @param  mailFile    the temporary file name
205 yi.zhou      1.3      */
206                       void _openFile(
207 kumpf        1.7          FILE** filePtr,
208                           char* mailFile);
209 yi.zhou      1.1  };
210                   
211                   PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2