Back to index

lightning-sunbird  0.9+nobinonly
readmail.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 //
00038 #include <windows.h>
00039 #include <windowsx.h>
00040 
00041 #ifndef MAPI_OLE     // Because MSFT doesn't do this for us :-(
00042 #include <mapi.h>
00043 #endif
00044 
00045 #include "port.h"
00046 #include "resource.h"
00047 
00048 //
00049 // Variables...
00050 // 
00051 extern HINSTANCE   hInst;
00052 extern HINSTANCE   m_hInstMapi;
00053 extern LHANDLE     mapiSession;
00054 
00055 // 
00056 // Forward declarations...
00057 //
00058 extern void   ShowMessage(HWND hWnd, LPSTR msg);
00059 extern void   SetFooter(LPSTR msg);
00060 extern LPSTR  GetMAPIError(LONG errorCode);
00061 lpMapiMessage mailPtr = NULL;
00062 
00063 void 
00064 ProcessReadMailCommand(HWND hWnd, int id, HWND hCtl, UINT codeNotify) 
00065 { 
00066   switch (id) 
00067   {
00068   case ID_OK:
00069   case IDCANCEL:
00070     EndDialog(hWnd, 0);
00071     break;
00072 
00073   default:
00074     break;
00075   }
00076 }
00077 
00078 BOOL CALLBACK LOADDS 
00079 ReadMailDlgProc(HWND hWndMail, UINT wMsg, WPARAM wParam, LPARAM lParam) 
00080 {
00081   switch (wMsg) 
00082   {
00083   case WM_INITDIALOG: 
00084     {
00085       DWORD i;
00086       // Do everything we need to display the message pointed to by
00087       // mailPtr
00088       if (!mailPtr)
00089         break;
00090 
00091       // Start with the basics...
00092       SetDlgItemText(hWndMail, IDC_EDIT_SUBJECT, mailPtr->lpszSubject);
00093       SetDlgItemText(hWndMail, IDC_EDIT_DATETIME, mailPtr->lpszDateReceived);
00094       SetDlgItemText(hWndMail, IDC_EDIT_THREAD, mailPtr->lpszConversationID);
00095       SetDlgItemText(hWndMail, IDC_EDIT_BODYTEXT, mailPtr->lpszNoteText);
00096 
00097       char    buf[1024];
00098       wsprintf(buf, "%s (%s)", mailPtr->lpOriginator->lpszName, 
00099                               mailPtr->lpOriginator->lpszAddress);
00100       SetDlgItemText(hWndMail, IDC_EDIT_FROM, buf);
00101 
00102       for (i=0; i<mailPtr->nRecipCount; i++)
00103       {
00104           wsprintf(buf, "%s (%s)", mailPtr->lpRecips[i].lpszName, 
00105                                    mailPtr->lpRecips[i].lpszAddress);
00106           ListBox_InsertString(GetDlgItem(hWndMail, IDC_LIST_RECIPIENTS), 
00107                   ListBox_GetCount(GetDlgItem(hWndMail, IDC_LIST_RECIPIENTS)), 
00108                   buf);
00109       }
00110 
00111       for (i=0; i<mailPtr->nFileCount; i++)
00112       {
00113           ListBox_InsertString(GetDlgItem(hWndMail, IDC_LIST_ATTACHMENTS), 
00114                 ListBox_GetCount(GetDlgItem(hWndMail, IDC_LIST_ATTACHMENTS)), 
00115                 mailPtr->lpFiles[i].lpszPathName);
00116       }
00117     }
00118     break;
00119 
00120   case WM_COMMAND:
00121     HANDLE_WM_COMMAND(hWndMail, wParam, lParam, ProcessReadMailCommand);
00122     break;
00123 
00124   default:
00125     return FALSE;
00126   }
00127   
00128   return TRUE;
00129 }
00130 
00131 void
00132 DisplayMAPIReadMail(HWND hWnd, lpMapiMessage msgPtr)
00133 {
00134   mailPtr = msgPtr;
00135   DialogBox(hInst, MAKEINTRESOURCE(ID_DIALOG_READMAIL), hWnd, 
00136                 (DLGPROC)ReadMailDlgProc);
00137 }