if (NS_SUCCEEDED(INTL_DecodeMimePartIIStr(bString, encodedCharset, decodedString))) { if (NS_SUCCEEDED(ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) { mMsgCompFields->SetSubject(aCString, NULL); PR_Free(aCString); } }
nsComposeAppCore::NewMessage(nsAutoString& aUrl,                             nsIDOMXULTreeElement *tree,                             nsIDOMNodeList *nodeList,                             nsIDOMMsgAppCore * msgAppCore,                             PRInt32 messageType){	//char *  urlstr=nsnull;	nsresult rv;	nsString controllerCID;	nsIAppShellService* appShell;    rv = nsServiceManager::GetService(kAppShellServiceCID,                                      nsIAppShellService::GetIID(),                                      (nsISupports**)&appShell);    if (NS_FAILED(rv)) return rv;	nsIURL* url = nsnull;	nsINetService * pNetService;	rv = nsServiceManager::GetService(kNetServiceCID, nsINetService::GetIID(), (nsISupports **)&pNetService);	if (NS_SUCCEEDED(rv) && pNetService) {		rv = pNetService->CreateURL(&url, aUrl);		NS_RELEASE(pNetService);		if (NS_FAILED(rv))			goto done;	}	else		goto done;	nsIWebShellWindow* newWindow;	controllerCID = "6B75BB61-BD41-11d2-9D31-00805F8ADDDF";	appShell->CreateTopLevelWindow(nsnull,      // parent                                   url,                                   controllerCID,                                   newWindow,   // result widget                                   nsnull,      // observer                                   this,      // callbacks                                   615,         // width                                   650);        // height	  // Get the default charset from pref, use this as a mail charset.  // TODO: For reply/forward, original charset need to be used instead.  mMsgCompFields->SetCharacterSet(INTL_GetDefaultMailCharset(), NULL);	if (tree && nodeList && msgAppCore) {		nsCOMPtr<nsISupports> object;		rv = msgAppCore->GetRDFResourceForMessage(tree, nodeList,                                                   getter_AddRefs(object));		if ((NS_SUCCEEDED(rv)) && object) {			nsCOMPtr<nsIMessage> message;			rv = object->QueryInterface(nsIMessage::GetIID(),                                         getter_AddRefs(message));			if ((NS_SUCCEEDED(rv)) && message) {				nsString aString = "";				nsString bString = "";				message->GetSubject(aString);                switch (messageType)                {                default:                        case 0:         // reply to sender                case 1:         // reply to all                {                    bString += "Re: ";                    bString += aString;					mMsgCompFields->SetSubject(nsAutoCString(bString), NULL);                    					message->GetAuthor(aString);							mMsgCompFields->SetTo(nsAutoCString(aString), NULL);                    if (messageType == 1)                    {                        nsString cString, dString;                        message->GetRecipients(cString);                        message->GetCCList(dString);                        if (cString.Length() > 0 && dString.Length() > 0)                            cString = cString + ", ";                        cString = cString + dString;						mMsgCompFields->SetCc(nsAutoCString(cString), NULL);                    }                    HackToGetBody(1);                    break;                }                case 2:         // forward as attachment                case 3:         // forward as inline                case 4:         // forward as quoted                {                    bString += "[Fwd: ";                    bString += aString;                    bString += "]";					mMsgCompFields->SetSubject(nsAutoCString(bString), NULL);                    /* We need to get more information out from the message. */                    nsCOMPtr<nsIRDFResource> rdfResource;                    rv = object->QueryInterface(kIRDFResourceIID,                                                getter_AddRefs(rdfResource));                    if (rdfResource)                    {	                        nsXPIDLCString uri;                        rdfResource->GetValue( getter_Copies(uri) );                        nsString messageUri(uri);                    }                    if (messageType == 2)                        HackToGetBody(0);                    else if (messageType == 3)                        HackToGetBody(2);                    else                        HackToGetBody(1);                    break;                }                }                                }        }	}done:	NS_RELEASE(url);    (void)nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);	return NS_OK;}