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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2