/* INTL_DefaultWinCharSetID, Based on DefaultDocCSID, it determines which Win CSID to use for Display */ PUBLIC int16 INTL_DefaultWinCharSetID(iDocumentContext context) { if (context) { INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(context); if (INTL_GetCSIWinCSID(csi)) return INTL_GetCSIWinCSID(csi); } return INTL_DocToWinCharSetID(INTL_DefaultDocCharSetID(context)); }
MWContext *FE_CreateNewEditWindow(MWContext *pContext, URL_Struct *pURL) { if(pContext != NULL) { if(ABSTRACTCX(pContext)->IsDestroyed()) { TRACE("Context %p Destroyed :: CreateNewDocWindow Blocking\n", pContext); // Don't allow this to happen if the context has been destroyed... return(NULL); } MWContext *pRetval = ABSTRACTCX(pContext)->CreateNewDocWindow(pContext, pURL); if(pRetval != NULL) { return(pRetval); } } // Regardless of the type of context we currently are, we are going to // create a new CMainFrame. // The contexts can do whatever they want in the derived class, but this is // the base implementation. If they return a context, then we won't do this. // Cause a frame to open. if(NULL == theApp.m_EditTmplate->OpenDocumentFile(NULL)) { return(NULL); } // The new frame will be the last one in the application's frame list. CMainFrame *pFrame; CGenericFrame *pGenFrame; for(pGenFrame = theApp.m_pFrameList; pGenFrame->m_pNext; pGenFrame = pGenFrame->m_pNext) { /* No Body */; } pFrame = (CMainFrame *) pGenFrame; MWContext *pNewContext = pFrame->GetMainContext()->GetContext(); // Appropriate assignment of options/prefs can only happen if we are also // owned by a CMainFrame, check. if(pContext != NULL && ABSTRACTCX(pContext)->IsFrameContext() && pContext->type == MWContextBrowser){ pFrame->m_iCSID = INTL_DefaultDocCharSetID(pContext); } // Set the miscellaneous XP context properties. if(pContext != NULL) { pNewContext->fancyFTP = pContext->fancyFTP; pNewContext->fancyNews = pContext->fancyNews; // Copy the session history over. SHIST_CopySession(pNewContext, pContext); } // If there was no URL specified to load, load what's in the history. // Only take URLs from a browser window. if(pURL == NULL) { // Load the oldest thing in it's history (most likely the home page). XP_List *pOldest = SHIST_GetList(pNewContext); History_entry *pEntry = (History_entry *)XP_ListNextObject(pOldest); if(pEntry == NULL) { // Nothing to load, we're done. return(pNewContext); } // don't load from non browser windows. if(pContext == NULL || pContext->type == MWContextBrowser || pContext->type == MWContextPane) { URL_Struct *pUrl = SHIST_CreateURLStructFromHistoryEntry(pContext ? pContext : pNewContext, pEntry); if(pUrl == NULL) { // Nothing to load? we're done. return(pNewContext); } // Set the current session history for the new context. SHIST_SetCurrent(&(pNewContext->hist), 0); // finally Load it. ABSTRACTCX(pNewContext)->GetUrl(pUrl, FO_CACHE_AND_EDIT); } } else if(pURL != NULL) { // Load the URL passed into this function. ABSTRACTCX(pNewContext)->GetUrl(pURL, FO_CACHE_AND_EDIT); } // New frame window up, and filled out appropriately. return(pNewContext); }
MWContext *CFE_CreateNewDocWindow(MWContext *pContext, URL_Struct *pURL) { if(pContext != NULL) { if(ABSTRACTCX(pContext)->IsDestroyed()) { TRACE("Context %p Destroyed :: CreateNewDocWindow Blocking\n", pContext); // Don't allow this to happen if the context has been destroyed... return(NULL); } MWContext *pRetval = ABSTRACTCX(pContext)->CreateNewDocWindow(pContext, pURL); if(pRetval != NULL) { return(pRetval); } } // Regardless of the type of context we currently are, we are going to // create a new CMainFrame. // The contexts can do whatever they want in the derived class, but this is // the base implementation. If they return a context, then we won't do this. // Cause a frame to open. if(NULL == theApp.m_ViewTmplate->OpenDocumentFile(NULL)) { return(NULL); } // The new frame will be the last one in the application's frame list. CMainFrame *pFrame; CGenericFrame *pGenFrame; for(pGenFrame = theApp.m_pFrameList; pGenFrame->m_pNext; pGenFrame = pGenFrame->m_pNext) { /* No Body */; } pFrame = (CMainFrame *) pGenFrame; MWContext *pNewContext = pFrame->GetMainContext()->GetContext(); // Appropriate assignment of options/prefs can only happen if we are also // owned by a CMainFrame, check. if(pContext != NULL) { if (ABSTRACTCX(pContext)->IsFrameContext() && pContext->type == MWContextBrowser) { // Assign over our options. // Toolbars... LPNSTOOLBAR pIToolBar = NULL; pFrame->GetChrome()->QueryInterface( IID_INSToolBar, (LPVOID *) &pIToolBar ); if ( pIToolBar ) { pIToolBar->Release(); } // Directory buttons and location box and Default Encoding. pFrame->GetChrome()->ShowToolbar(ID_LOCATION_TOOLBAR, pFrame->m_bLocationBar ); pFrame->m_iCSID = INTL_DefaultDocCharSetID(pContext); } // Set the miscellaneous XP context properties. pNewContext->fancyFTP = pContext->fancyFTP; pNewContext->fancyNews = pContext->fancyNews; // Copy the session history over ONLY if called from a Browser if(pContext->type == MWContextBrowser && !EDT_IS_EDITOR(pContext)) { SHIST_CopySession(pNewContext, pContext); } } // If there was no URL specified to load, load what's in the history. // Only take URLs from a browser window. if(pURL == NULL) { // Make sure we're coming from a context we understand, otherwise get out now. if(pContext == NULL || EDT_IS_EDITOR(pContext) || pContext->type != MWContextBrowser) { // In this case, load the home page. pFrame->OnLoadHomePage(); } else { // Load the oldest thing in it's history (most likely the home page). // This current entry was set above, all we have to do is go through // the motions of a reload. ABSTRACTCX(pNewContext)->Reload(); } } else if(pURL != NULL) { // Load the URL passed into this function. ABSTRACTCX(pNewContext)->GetUrl(pURL, FO_CACHE_AND_PRESENT); } // New frame window up, and filled out appropriately. return(pNewContext); }
PUBLIC Stream * INTL_ConvCharCode (int format_out, void *data_obj, URL_Struct *URL_s, MWContext *mwcontext) { NetStreamData *nsd; CCCDataObject obj; Stream *stream; iDocumentContext doc_context = (iDocumentContext)mwcontext; INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(doc_context); XP_Bool is_metacharset_reload; uint16 default_doc_csid = INTL_DefaultDocCharSetID(mwcontext); /* Should this be ? uint16 default_doc_csid = FE_DefaultDocCharSetID(mwcontext); */ TRACEMSG(("Setting up display stream. Have URL: %s\n", URL_s->address)); stream = XP_NEW_ZAP(Stream); if(stream == NULL) return(NULL); stream->name = "CharCodeConverter"; stream->complete = (MKStreamCompleteFunc) net_CvtCharCodeComplete; stream->abort = (MKStreamAbortFunc) net_CvtCharCodeAbort; stream->is_write_ready = (MKStreamWriteReadyFunc) net_CvtCharCodeWriteReady; stream->window_id = doc_context; /* initialize the doc_csid (etc.) unless if this is a reload caused by meta charset */ if ((NET_RESIZE_RELOAD == URL_s->resize_reload) && (METACHARSET_FORCERELAYOUT == INTL_GetCSIRelayoutFlag(c))) is_metacharset_reload = TRUE; else is_metacharset_reload = FALSE; INTL_CSIInitialize(c, is_metacharset_reload, URL_s->charset, mwcontext->type, default_doc_csid); obj = INTL_CreateDocumentCCC(c, default_doc_csid); if (obj == NULL) { XP_FREE(stream); return(NULL); } nsd = XP_NEW_ZAP(NetStreamData); if(nsd == NULL) { XP_FREE(stream); XP_FREE(obj); return(NULL); } nsd->current_stream = stream; nsd->obj = obj; stream->data_object = nsd; /* document info object */ INTL_SetCCCReportAutoDetect(obj, net_report_autodetect, nsd); if (INTL_GetCSIDocCSID(c) == CS_DEFAULT || INTL_GetCSIDocCSID(c) == CS_UNKNOWN) { /* we know the default converter but do not install it yet. * Instead wait until the first block and see if we can determine * what the actual charset is from http/meta tags or from the * first block. By delaying we can avoid a reload if * we get a different charset from http/meta tag or the first block. */ stream->put_block = (MKStreamWriteFunc) net_AutoCharCodeConv; } else { if (INTL_GetCCCCvtfunc(obj) == NULL) stream->put_block = (MKStreamWriteFunc) net_NoCharCodeConv; else if (INTL_GetCCCCvtfunc(obj) == (CCCFunc)One2OneCCC) stream->put_block = (MKStreamWriteFunc) net_1to1CCC; else stream->put_block = (MKStreamWriteFunc) net_CharCodeConv; } TRACEMSG(("Returning stream from NET_CvtCharCodeConverter\n")); /* remap content type to be to INTERNAL_PARSER */ StrAllocCopy(URL_s->content_type, INTERNAL_PARSER); #ifdef JSDEBUGGER nsd->next_stream = LM_StreamBuilder(format_out, NULL, URL_s, mwcontext); #else nsd->next_stream = NET_StreamBuilder(format_out, URL_s, doc_context); #endif /* JSDEBUGGER */ if(!nsd->next_stream) { XP_FREE(obj); XP_FREE(stream); XP_FREE(nsd); return(NULL); } return stream; }
// // 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); }