PRIVATE void net_report_autodetect(void *closure, CCCDataObject obj, uint16 doc_csid) { NetStreamData *nsd = (NetStreamData *)closure; iDocumentContext doc_context = nsd->current_stream->window_id; CCCFunc cvtfunc = INTL_GetCCCCvtfunc(obj); INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(doc_context); INTL_SetCSIDocCSID(c, doc_csid); /* I hope it is okay, to set the win_csid */ INTL_SetCSIWinCSID(c, INTL_GetCCCToCSID(obj)); if (cvtfunc == NULL) nsd->current_stream->put_block = (MKStreamWriteFunc) net_NoCharCodeConv; }
PUBLIC NET_StreamClass * net_ColorHTMLStream (int format_out, void *data_obj, URL_Struct *URL_s, MWContext *window_id) { DataObject* obj; char *new_markup=0; char *new_url=0; char *old_url; int status, type; NET_StreamClass *next_stream, *new_stream; Bool is_html_stream = FALSE; INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(window_id); INTL_CharSetInfo next_csi; TRACEMSG(("Setting up ColorHTML stream. Have URL: %s\n", URL_s->address)); /* treat the stream as html if the closure data says * it's HTML and it is also not a mail or news message */ type = NET_URL_Type(URL_s->address); if(data_obj && !XP_STRCMP((char *)data_obj, TEXT_HTML) && type != MAILBOX_TYPE_URL && type != IMAP_TYPE_URL && type != NEWS_TYPE_URL) is_html_stream = TRUE; /* use a new named window */ StrAllocCopy(URL_s->window_target, VIEW_SOURCE_TARGET_WINDOW_NAME); /* add the url address to the name so that there can be * one view source window per url */ StrAllocCat(URL_s->window_target, URL_s->address); /* zero position_tag to prevent hash lossage */ URL_s->position_tag = 0; /* alloc a new chrome struct and stick it in the URL * so that we can turn off the relavent stuff */ URL_s->window_chrome = XP_NEW(Chrome); if(URL_s->window_chrome) { /* zero everything to turn off all chrome */ XP_MEMSET(URL_s->window_chrome, 0, sizeof(Chrome)); URL_s->window_chrome->type = MWContextDialog; URL_s->window_chrome->show_scrollbar = TRUE; URL_s->window_chrome->allow_resize = TRUE; URL_s->window_chrome->allow_close = TRUE; } /* call the HTML parser */ StrAllocCopy(URL_s->content_type, INTERNAL_PARSER); /* use the view-source: url instead */ StrAllocCopy(new_url, VIEW_SOURCE_URL_PREFIX); StrAllocCat(new_url, URL_s->address); old_url = URL_s->address; URL_s->address = new_url; format_out = FO_PRESENT; /* open next stream */ next_stream = NET_StreamBuilder(format_out, URL_s, window_id); if(!next_stream) { FREE(old_url); return(NULL); } next_csi = LO_GetDocumentCharacterSetInfo(next_stream->window_id); /* jliu: for international's reason, set the value ASAP, so the following stream can share it */ INTL_SetCSIWinCSID(next_csi, INTL_GetCSIWinCSID(csi)); INTL_SetCSIDocCSID(next_csi, INTL_GetCSIDocCSID(csi)); #define DEF_PICS_LABEL "<META http-equiv=PICS-Label content='(PICS-1.0 \"http://home.netscape.com/default_rating\" l gen true r (s 0))'>" /* add a PICS label */ StrAllocCopy(new_markup, DEF_PICS_LABEL); StrAllocCat(new_markup, "<TITLE>"); StrAllocCat(new_markup, XP_GetString(MK_CVCOLOR_SOURCE_OF)); StrAllocCat(new_markup, old_url); StrAllocCat(new_markup, "</TITLE><BODY BGCOLOR=#C0C0C0>"); if(!is_html_stream) StrAllocCat(new_markup, "<PLAINTEXT>"); else StrAllocCat(new_markup, "<PRE>"); FREE(old_url); status = (*next_stream->put_block)(next_stream, new_markup, XP_STRLEN(new_markup)); FREE(new_markup); if(status < 0) { (*next_stream->abort)(next_stream, status); FREE(next_stream); return(NULL); } if(!is_html_stream) return(next_stream); /* else; continue on and build up this stream module * and attach the next stream to it */ new_stream = XP_NEW(NET_StreamClass); if(new_stream == NULL) { (*next_stream->abort)(next_stream, status); FREE(next_stream); return(NULL); } obj = XP_NEW(DataObject); if (obj == NULL) { (*next_stream->abort)(next_stream, status); FREE(next_stream); FREE(new_stream); return(NULL); } XP_MEMSET(obj, 0, sizeof(DataObject)); obj->state = IN_CONTENT; obj->next_stream = next_stream; obj->tag_type = P_UNKNOWN; new_stream->name = "HTML Colorer"; new_stream->complete = (MKStreamCompleteFunc) net_ColorHTMLComplete; new_stream->abort = (MKStreamAbortFunc) net_ColorHTMLAbort; new_stream->put_block = (MKStreamWriteFunc) net_ColorHTMLWrite; new_stream->is_write_ready = (MKStreamWriteReadyFunc) net_ColorHTMLWriteReady; new_stream->data_object = (void *) obj; /* document info object */ new_stream->window_id = window_id; TRACEMSG(("Returning stream from HTMLColorConverter\n")); return new_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); }