BOOL CCustomHeadersDlg::OnInitDialog() { CDialog::OnInitDialog(); MSG_FolderInfo *pInbox = NULL; MSG_GetFoldersWithFlag (WFE_MSGGetMaster(), MSG_FOLDER_FLAG_INBOX, &pInbox, 1); uint16 numItems; MSG_GetNumAttributesForFilterScopes (WFE_MSGGetMaster(), scopeMailFolder, (void**)&pInbox, 1, &numItems); MSG_SearchMenuItem * pHeaderItems = new MSG_SearchMenuItem [numItems]; if (!pHeaderItems) return FALSE; //something bad happened here!! MSG_GetAttributesForFilterScopes (WFE_MSGGetMaster(), scopeMailFolder, (void**)&pInbox, 1, pHeaderItems, &numItems); for (int i=0; i < numItems; i++) { if ( (pHeaderItems[i].attrib == attribOtherHeader) && pHeaderItems[i].isEnabled ) { m_lbHeaderList.AddString(pHeaderItems[i].name); } } delete pHeaderItems; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
LRESULT CMessageFrame::OnFillInToolTip(WPARAM wParam, LPARAM lParam) { HWND hwnd = (HWND)wParam; LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT) lParam; CToolbarButton *pButton = (CToolbarButton *) CWnd::FromHandle(hwnd); UINT nCommand = pButton->GetButtonCommand(); LPCSTR pTipText = pButton->GetToolTipText(); LPCSTR pText = NULL; CString cs; if( nCommand == ID_NAVIGATE_CONTAINER ) { MSG_FolderLine folderLine; MSG_FolderInfo *folderInfo = GetCurFolder(); // XXX WHS Int'lize if ( MSG_GetFolderLineById( WFE_MSGGetMaster(), folderInfo, &folderLine ) ) { cs.Format("Open %s", folderLine.prettyName ? folderLine.prettyName : folderLine.name ); pText = (LPCSTR) cs; } } lpttt->szText[79] = '\0'; if( !pText || !pText[0] ) strncpy(lpttt->szText, pTipText, 79); else strncpy(lpttt->szText, pText, 79); return 1; }
void CMessageFrame::OnMove(UINT nID) { if ( m_pPane ) { MSG_FolderInfo *folderInfoCur; MSG_ViewIndex idxCur; MessageKey idCur; MSG_GetCurMessage( m_pPane, &folderInfoCur, &idCur, &idxCur ); MSG_FolderInfo *folderInfo = FolderInfoFromMenuID( nID ); ASSERT(folderInfo); if (folderInfo) { MSG_FolderLine folderLine; MSG_GetFolderLineById( WFE_MSGGetMaster(), folderInfo, &folderLine ); // We want to make file behave for newsgroups if ( folderLine.flags & MSG_FOLDER_FLAG_NEWSGROUP ) { MSG_CopyMessagesIntoFolder( m_pPane, &idxCur, 1, folderInfo); } else { MSG_MoveMessagesIntoFolder( m_pPane, &idxCur, 1, folderInfo); } ModalStatusBegin( MODAL_DELAY ); } } }
BOOL CChooseFolderDialog::OnInitDialog() { BOOL ret = CDialog::OnInitDialog(); if (m_nTypeID == TYPE_SENTNEWS) SetDlgItemText(IDC_STATIC_TITLE, szLoadString(IDS_COPY_NEWS_MSG)); else if (m_nTypeID == TYPE_DRAFT) SetDlgItemText(IDC_STATIC_TITLE, szLoadString(IDS_COPY_DRAFTS)); else if (m_nTypeID == TYPE_TEMPLATE) SetDlgItemText(IDC_STATIC_TITLE, szLoadString(IDS_COPY_TEMPLATES)); CString formatString, defaultTitle; formatString.LoadString(IDS_SPECIAL_FOLDER); defaultTitle.Format(LPCTSTR(formatString), XP_GetString(m_nDefaultID)); SetDlgItemText(IDC_RADIO_SENT, LPCTSTR(defaultTitle)); if ( ret ) { // Subclass Server combo m_ServerCombo.SubclassDlgItem( IDC_COMBO_SERVERS, this ); m_ServerCombo.NoPrettyName(); m_ServerCombo.PopulateMailServer( WFE_MSGGetMaster() ); if (SetServerComboCurSel(m_ServerCombo.GetSafeHwnd(), m_pFolderPath, m_nDefaultID)) CheckDlgButton(IDC_RADIO_SENT, TRUE); else CheckDlgButton(IDC_RADIO_OTHER, TRUE); // Subclass folder combo m_FolderCombo.SubclassDlgItem( IDC_COMBO_FOLDERS, this ); m_FolderCombo.PopulateMail( WFE_MSGGetMaster() ); SetFolderComboCurSel(m_FolderCombo.GetSafeHwnd(), m_pFolderPath, m_nDefaultID); } return ret; }
void CChooseFolderDialog::OnNewFolder() { CPrefNewFolderDialog newFolderDlg( this, NULL); if (IDOK == newFolderDlg.DoModal()) { MSG_FolderInfo *pNewFolder = newFolderDlg.GetNewFolder(); m_FolderCombo.PopulateMail(WFE_MSGGetMaster()); for (int i = m_FolderCombo.GetCount(); i >= 0 ; i--) { MSG_FolderInfo *pFolderInfo = (MSG_FolderInfo*)m_FolderCombo.GetItemData(i); if (pNewFolder == pFolderInfo) { m_FolderCombo.SetCurSel(i); break; } } OnSelectFolder(); //check the radio button } }
BOOL CMessageFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { // Skip up to CGenericFrame, since CMailNewsFrame doesn't call it BOOL res = CGenericFrame::OnCreateClient( lpcs, pContext ); if (res) { CWnd *pView = GetDescendantWindow(IDW_MESSAGE_PANE, TRUE); ASSERT(pView); CWinCX *pWinCX; pWinCX = new CWinCX((CGenericDoc *) pContext->m_pCurrentDoc, this, (CGenericView *)pView); pView = GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE); m_pMessageView = DYNAMIC_DOWNCAST(CMessageView, pView); ASSERT(m_pMessageView); SetMainContext(pWinCX); SetActiveContext(pWinCX); RECT rect; GetClientRect(&rect); pWinCX->Initialize(FALSE, &rect); pWinCX->GetContext()->type = MWContextMailMsg; pWinCX->GetContext()->fancyFTP = TRUE; pWinCX->GetContext()->fancyNews = TRUE; pWinCX->GetContext()->intrupt = FALSE; pWinCX->GetContext()->reSize = FALSE; m_pMaster = WFE_MSGGetMaster(); m_pPane = MSG_CreateMessagePane( pWinCX->GetContext(), m_pMaster ); m_pMessagePane = m_pPane; MSG_SetFEData(m_pPane, (LPVOID) (LPUNKNOWN) this ); MSG_SetMessagePaneCallbacks(m_pMessagePane, &MsgPaneCB, NULL); } return res; }
void CChooseFolderDialog::OnOK() { MSG_FolderInfo *pFolder = NULL; MSG_FolderLine folderLine; MSG_Master* pMaster = WFE_MSGGetMaster(); if (IsDlgButtonChecked(IDC_RADIO_SENT)) { pFolder = (MSG_FolderInfo*)m_ServerCombo.GetItemData(m_ServerCombo.GetCurSel()); m_szFolder = XP_GetString(m_nDefaultID); if (MSG_GetFolderLineById(pMaster, pFolder, &folderLine)) m_szServer = folderLine.name; URL_Struct *url = MSG_ConstructUrlForFolder(NULL, pFolder); if (MK_MSG_SENT_L10N_NAME == m_nDefaultID && MAILBOX_TYPE_URL == NET_URL_Type(url->address)) { //local mail int nPos = strlen("mailbox:/"); m_szPrefUrl = &url->address[nPos]; m_szPrefUrl += "\\"; m_szPrefUrl += m_szFolder; LPTSTR pBuffer = m_szPrefUrl.GetBuffer(m_szPrefUrl.GetLength()); UnixToDosString(pBuffer); m_szPrefUrl.ReleaseBuffer(); } else { //imap m_szPrefUrl = url->address; // m_szPrefUrl += "/"; // m_szPrefUrl += m_szFolder; } } else if (IsDlgButtonChecked(IDC_RADIO_OTHER)) { pFolder = (MSG_FolderInfo*)m_FolderCombo.GetItemData(m_FolderCombo.GetCurSel()); if (MSG_GetFolderLineById(pMaster, pFolder, &folderLine)) { m_szFolder = folderLine.name; MSG_FolderInfo* pHostFolderInfo = GetHostFolderInfo(pFolder); if (pHostFolderInfo) { //imap if (MSG_GetFolderLineById(pMaster, pHostFolderInfo, &folderLine)) m_szServer = folderLine.name; URL_Struct *url = MSG_ConstructUrlForFolder(NULL, pFolder); m_szPrefUrl = url->address; } else { //local mail m_szServer = XP_GetString(MK_MSG_LOCAL_MAIL); URL_Struct *url = MSG_ConstructUrlForFolder(NULL, pFolder); if (MK_MSG_SENT_L10N_NAME == m_nDefaultID) { int nPos = strlen("mailbox:/"); m_szPrefUrl = &url->address[nPos]; LPTSTR pBuffer = m_szPrefUrl.GetBuffer(m_szPrefUrl.GetLength()); UnixToDosString(pBuffer); m_szPrefUrl.ReleaseBuffer(); } else m_szPrefUrl = url->address; } } } CDialog::OnOK(); }
// // This function will create a composition window and either do // a blind send or pop up the compose window for the user to // complete the operation // // Return: appropriate MAPI return code... // // extern "C" LONG DoFullMAPIMailOperation(MAPISendMailType *sendMailPtr, const char *pInitialText, BOOL winShowFlag) { CGenericDoc *pDocument; LPSTR subject; NSstringSeq mailInfoSeq; DWORD stringCount = 6; DWORD i; CString csDefault; // Get a context to use for this call... MWContext *pOldContext = GetUsableContext(); if (!pOldContext) { return(MAPI_E_FAILURE); } // Don't allow a compose window to be created if the user hasn't // specified an email address const char *real_addr = FE_UsersMailAddress(); if (MISC_ValidateReturnAddress(pOldContext, real_addr) < 0) { return(MAPI_E_FAILURE); } // // Now, we must build the fields object... // mailInfoSeq = (NSstringSeq) &(sendMailPtr->dataBuf[0]); subject = NSStrSeqGet(mailInfoSeq, 0); // We should give it a subject to preven the prompt from coming // up... if ((!subject) || !(*subject)) { csDefault.LoadString(IDS_COMPOSE_DEFAULTNOSUBJECT); subject = csDefault.GetBuffer(2); } TRACE("MAPI: ProcessMAPISendMail() Subject = [%s]\n", subject); TRACE("MAPI: ProcessMAPISendMail() Text Size = [%d]\n", strlen((const char *)pInitialText)); TRACE("MAPI: ProcessMAPISendMail() # of Recipients = [%d]\n", sendMailPtr->MSG_nRecipCount); char toString[1024] = ""; char ccString[1024] = ""; char bccString[1024] = ""; for (i=0; i<sendMailPtr->MSG_nRecipCount; i++) { LPSTR ptr; UCHAR tempString[256]; ULONG addrType = atoi(NSStrSeqGet(mailInfoSeq, stringCount++)); // figure which type of address this is? if (addrType == MAPI_CC) ptr = ccString; else if (addrType == MAPI_BCC) ptr = bccString; else ptr = toString; LPSTR namePtr = (LPSTR) NSStrSeqGet(mailInfoSeq, stringCount++); LPSTR emailPtr = (LPSTR) NSStrSeqGet(mailInfoSeq, stringCount++); if ( (lstrlen(emailPtr) > 5) && (*(emailPtr + 4) == ':') ) { emailPtr += 5; } // Now build the temp string to tack on in the format // "Rich Pizzarro" <*****@*****.**> wsprintf((LPSTR) tempString, "\"%s\" <%s>", namePtr, emailPtr); // add a comma if not the first one if (ptr[0] != '\0') lstrcat(ptr, ","); // tack on string! lstrcat(ptr, (LPSTR) tempString); } BOOL bEncrypt = FALSE; BOOL bSign = FALSE; PREF_GetBoolPref("mail.crypto_sign_outgoing_mail", &bSign); PREF_GetBoolPref("mail.encrypt_outgoing_mail", &bEncrypt); MSG_CompositionFields *fields = MSG_CreateCompositionFields(real_addr, real_addr, toString, ccString, bccString, "", "", "", "", subject, "", "", "", "", "", bEncrypt, bSign); if (!fields) { return(MAPI_E_FAILURE); } // RICHIE // INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pOldContext); // int16 win_csid = INTL_GetCSIWinCSID(csi); pDocument = (CGenericDoc*)theApp.m_TextComposeTemplate->OpenDocumentFile(NULL, NULL, /*win_csid RICHIE*/ winShowFlag); if ( !pDocument ) { return(MAPI_E_FAILURE); } CWinCX * pContext = (CWinCX*) pDocument->GetContext(); if ( !pContext ) { return(MAPI_E_FAILURE); } MSG_CompositionPaneCallbacks Callbacks; Callbacks.CreateRecipientsDialog = CreateRecipientsDialog; Callbacks.CreateAskHTMLDialog = CreateAskHTMLDialog; int16 doccsid; MWContext *context = pContext->GetContext(); CComposeFrame *pCompose = (CComposeFrame *) pContext->GetFrame()->GetFrameWnd(); pCompose->SetComposeStuff(context, fields); // squirl away stuff for post-create // This needs to be set TRUE if using the old non-HTML text frame // to prevent dropping dragged URLs pContext->m_bDragging = !pCompose->UseHtml(); if (!pCompose->UseHtml()) { pCompose->SetMsgPane( MSG_CreateCompositionPane(pContext->GetContext(), context, g_MsgPrefs.m_pMsgPrefs, fields, WFE_MSGGetMaster()) ); } ASSERT(pCompose->GetMsgPane()); MSG_SetFEData(pCompose->GetMsgPane(),(void *)pCompose); pCompose->UpdateAttachmentInfo(); // Pass doccsid info to new context for MailToWin conversion doccsid = INTL_GetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context)); INTL_SetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context), (doccsid ? doccsid : INTL_DefaultDocCharSetID(context))); pCompose->DisplayHeaders(NULL); CComposeBar * pBar = pCompose->GetComposeBar(); ASSERT(pBar); LPADDRESSCONTROL pIAddressList = pBar->GetAddressWidgetInterface(); if (!pIAddressList->IsCreated()) { pBar->CreateAddressingBlock(); } // rhp - Deal with addressing the brute force way! This is a // "fix" for bad behavior when creating these windows and not // showing them on the desktop. if (!winShowFlag) // Hack to fix the window not being mapped { pCompose->AppendAddress(MSG_TO_HEADER_MASK, ""); pCompose->AppendAddress(MSG_CC_HEADER_MASK, ""); pCompose->AppendAddress(MSG_BCC_HEADER_MASK, ""); } // Always do plain text composition! pCompose->CompleteComposeInitialization(); // Do this so we don't get popups on "empty" messages if ( (!pInitialText) || (!(*pInitialText)) ) pInitialText = " "; const char * pBody = pInitialText ? pInitialText : MSG_GetCompBody(pCompose->GetMsgPane()); if (pBody) { FE_InsertMessageCompositionText(context,pBody,TRUE); } // // Now set the message as being edited! // pCompose->SetModified(TRUE); // // Finally deal with the attachments... // if (sendMailPtr->MSG_nFileCount > 0) { // Send this puppy when done with the attachments... if (!winShowFlag) { pCompose->SetMAPISendMode(MAPI_SEND); } MSG_AttachmentData *pAttach = (MSG_AttachmentData *) XP_CALLOC((sendMailPtr->MSG_nFileCount + 1), sizeof(MSG_AttachmentData)); if (!pAttach) { return(MAPI_E_INSUFFICIENT_MEMORY); } memset(pAttach, 0, (sendMailPtr->MSG_nFileCount + 1) * sizeof(MSG_AttachmentData)); for (i=0; i<sendMailPtr->MSG_nFileCount; i++) { CString cs; // Create URL from filename... WFE_ConvertFile2Url(cs, (const char *)NSStrSeqGet(mailInfoSeq, stringCount++)); pAttach[i].url = XP_STRDUP(cs); // Now also include the "display" name... StrAllocCopy(pAttach[i].real_name, NSStrSeqGet(mailInfoSeq, stringCount++)); } // Set the list! MSG_SetAttachmentList(pCompose->GetMsgPane(), pAttach); // Now free everything... for (i=0; i<sendMailPtr->MSG_nFileCount; i++) { if (pAttach[i].url) XP_FREE(pAttach[i].url); if (pAttach[i].real_name) XP_FREE(pAttach[i].real_name); } XP_FREE(pAttach); } // // Now, if we were supposed to do the blind send...do it, otherwise, // just popup the window... // if (winShowFlag) { // Post message to compose window to set the initial focus. pCompose->PostMessage(WM_COMP_SET_INITIAL_FOCUS); } else if (sendMailPtr->MSG_nFileCount <= 0) // Send NOW if no attachments! { pCompose->PostMessage(WM_COMMAND, IDM_SEND); } return(SUCCESS_SUCCESS); }
// // This function will create a composition window and just attach // the attachments of interest and pop up the window... // // Return: appropriate MAPI return code... // // extern "C" LONG DoPartialMAPIMailOperation(MAPISendDocumentsType *sendDocPtr) { CGenericDoc *pDocument; // Get a context to use for this call... MWContext *pOldContext = GetUsableContext(); if (!pOldContext) { return(MAPI_E_FAILURE); } // Don't allow a compose window to be created if the user hasn't // specified an email address const char *real_addr = FE_UsersMailAddress(); if (MISC_ValidateReturnAddress(pOldContext, real_addr) < 0) { return(MAPI_E_FAILURE); } // // Now, build the fields object w/o much info... // BOOL bEncrypt = FALSE; BOOL bSign = FALSE; PREF_GetBoolPref("mail.crypto_sign_outgoing_mail", &bSign); PREF_GetBoolPref("mail.encrypt_outgoing_mail", &bEncrypt); MSG_CompositionFields *fields = MSG_CreateCompositionFields(real_addr, real_addr, NULL, "", "", "", "", "", "", "", "", "", "", "", "", bEncrypt, bSign); if (!fields) { return(MAPI_E_FAILURE); } // RICHIE - INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pOldContext); // int16 win_csid = INTL_GetCSIWinCSID(csi); pDocument = (CGenericDoc*)theApp.m_TextComposeTemplate->OpenDocumentFile(NULL, NULL, /*RICHIE win_csid,*/ TRUE); if ( !pDocument ) { // cleanup fields object MSG_DestroyCompositionFields(fields); return(MAPI_E_FAILURE); } CWinCX * pContext = (CWinCX*) pDocument->GetContext(); if ( !pContext ) { return(MAPI_E_FAILURE); } MSG_CompositionPaneCallbacks Callbacks; Callbacks.CreateRecipientsDialog = CreateRecipientsDialog; Callbacks.CreateAskHTMLDialog = CreateAskHTMLDialog; MWContext *context = pContext->GetContext(); CComposeFrame *pCompose = (CComposeFrame *) pContext->GetFrame()->GetFrameWnd(); pCompose->SetComposeStuff(context,fields); // squirl away stuff for post-create // This needs to be set TRUE if using the old non-HTML text frame // to prevent dropping dragged URLs pContext->m_bDragging = !pCompose->UseHtml(); if (!pCompose->UseHtml()) { pCompose->SetMsgPane(MSG_CreateCompositionPane( pContext->GetContext(), context, g_MsgPrefs.m_pMsgPrefs, fields, WFE_MSGGetMaster())); } ASSERT(pCompose->GetMsgPane()); MSG_SetFEData(pCompose->GetMsgPane(),(void *)pCompose); pCompose->UpdateAttachmentInfo(); // Pass doccsid info to new context for MailToWin conversion /*** doccsid = INTL_GetCSIDocCSID(LO_GetDocumentCharacterSetInfo(pOldContext)); INTL_SetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context), (doccsid ? doccsid : INTL_DefaultDocCharSetID(pOldContext))); ****/ pCompose->DisplayHeaders(NULL); CComposeBar * pBar = pCompose->GetComposeBar(); ASSERT(pBar); LPADDRESSCONTROL pIAddressList = pBar->GetAddressWidgetInterface(); if (!pIAddressList->IsCreated()) { pBar->CreateAddressingBlock(); } // Always do plain text composition! pCompose->CompleteComposeInitialization(); // // Finally deal with the attachments... // NSstringSeq mailInfoSeq = (NSstringSeq) &(sendDocPtr->dataBuf[0]); DWORD stringCount = 0; DWORD i; TRACE("MAPI: ProcessMAPISendDocuments() # of Attachments = [%d]\n", sendDocPtr->nFileCount); if (sendDocPtr->nFileCount > 0) { MSG_AttachmentData *pAttach = (MSG_AttachmentData *) XP_CALLOC((sendDocPtr->nFileCount + 1), sizeof(MSG_AttachmentData)); if (!pAttach) { return(MAPI_E_INSUFFICIENT_MEMORY); } memset(pAttach, 0, (sendDocPtr->nFileCount + 1) * sizeof(MSG_AttachmentData)); for (i=0; i<sendDocPtr->nFileCount; i++) { CString cs; // Create URL from filename... WFE_ConvertFile2Url(cs, (const char *)NSStrSeqGet(mailInfoSeq, stringCount++)); pAttach[i].url = XP_STRDUP(cs); // Now also include the "display" name... StrAllocCopy(pAttach[i].real_name, NSStrSeqGet(mailInfoSeq, stringCount++)); } // Set the list! MSG_SetAttachmentList(pCompose->GetMsgPane(), pAttach); // Now free everything... for (i=0; i<sendDocPtr->nFileCount; i++) { if (pAttach[i].url) XP_FREE(pAttach[i].url); if (pAttach[i].real_name) XP_FREE(pAttach[i].real_name); } XP_FREE(pAttach); } // // Now some checking for ... well I'm not sure... // if (MSG_GetAttachmentList(pCompose->GetMsgPane())) pCompose->SetModified(TRUE); else pCompose->SetModified(FALSE); // Post message to compose window to set the initial focus. pCompose->PostMessage(WM_COMP_SET_INITIAL_FOCUS); // // Now, just popup the window... // pCompose->ShowWindow(TRUE); // return pCompose->GetMsgPane(); rhp - used to return the MsgPane return(SUCCESS_SUCCESS); }