//---------------------------------------------------------------------- nsresult GlobalPrinters::InitializeGlobalPrinters () { if (PrintersAreAllocated()) return NS_OK; mGlobalNumPrinters = 0; #ifdef USE_POSTSCRIPT mGlobalPrinterList = new nsStringArray(); if (!mGlobalPrinterList) return NS_ERROR_OUT_OF_MEMORY; /* add an entry for the default printer (see nsPostScriptObj.cpp) */ mGlobalPrinterList->AppendString( nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME "default"))); mGlobalNumPrinters++; /* get the list of printers */ char *printerList = nsnull; /* the env var MOZILLA_PRINTER_LIST can "override" the prefs */ printerList = PR_GetEnv("MOZILLA_PRINTER_LIST"); if (!printerList) { nsresult rv; nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { (void) pPrefs->CopyCharPref("print.printer_list", &printerList); } } if (printerList) { char *tok_lasts; char *name; /* PL_strtok_r() will modify the string - copy it! */ printerList = strdup(printerList); if (!printerList) return NS_ERROR_OUT_OF_MEMORY; for( name = PL_strtok_r(printerList, " ", &tok_lasts) ; name != nsnull ; name = PL_strtok_r(nsnull, " ", &tok_lasts) ) { mGlobalPrinterList->AppendString( nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME)) + nsString(NS_ConvertASCIItoUCS2(name))); mGlobalNumPrinters++; } free(printerList); } #endif /* USE_POSTSCRIPT */ if (mGlobalNumPrinters == 0) return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE; return NS_OK; }
static void GetMathMLAttributeStyleSheet(nsPresContext* aPresContext, nsIStyleSheet** aSheet) { static const char kTitle[] = "Internal MathML/CSS Attribute Style Sheet"; *aSheet = nsnull; // first, look if the attribute stylesheet is already there nsStyleSet *styleSet = aPresContext->StyleSet(); NS_ASSERTION(styleSet, "no style set"); nsAutoString title; for (PRInt32 i = styleSet->SheetCount(nsStyleSet::eAgentSheet) - 1; i >= 0; --i) { nsIStyleSheet *sheet = styleSet->StyleSheetAt(nsStyleSet::eAgentSheet, i); nsCOMPtr<nsICSSStyleSheet> cssSheet(do_QueryInterface(sheet)); if (cssSheet) { cssSheet->GetTitle(title); if (title.Equals(NS_ConvertASCIItoUCS2(kTitle))) { *aSheet = sheet; NS_IF_ADDREF(*aSheet); return; } } } // then, create a new one if it isn't yet there nsCOMPtr<nsIURI> uri; NS_NewURI(getter_AddRefs(uri), "about:internal-mathml-attribute-stylesheet"); if (!uri) return; nsCOMPtr<nsICSSStyleSheet_MOZILLA_1_8_BRANCH> cssSheet = do_CreateInstance(kCSSStyleSheetCID); if (!cssSheet) return; cssSheet->SetURIs18(uri, uri, uri); cssSheet->SetTitle(NS_ConvertASCIItoUCS2(kTitle)); // all done, no further activity from the net involved, so we better do this cssSheet->SetComplete(); nsCOMPtr<nsIDOMCSSStyleSheet> domSheet(do_QueryInterface(cssSheet)); if (domSheet) { PRUint32 index; domSheet->InsertRule(NS_LITERAL_STRING("@namespace url(http://www.w3.org/1998/Math/MathML);"), 0, &index); } // insert the stylesheet into the styleset without notifying observers // XXX Should this be at a different level? styleSet->PrependStyleSheet(nsStyleSet::eAgentSheet, cssSheet); *aSheet = cssSheet; NS_ADDREF(*aSheet); }
// // FUNCTION: OpenWebPage() // // PURPOSE: Opens a new browser dialog and starts it loading to the // specified url. // nsresult OpenWebPage(const char *url) { nsresult rv; // Create the chrome object. Note that it leaves this function // with an extra reference so that it can released correctly during // destruction (via Win32UI::Destroy) nsCOMPtr<nsIWebBrowserChrome> chrome; rv = AppCallbacks::CreateBrowserWindow(nsIWebBrowserChrome::CHROME_ALL, nsnull, getter_AddRefs(chrome)); if (NS_SUCCEEDED(rv)) { // Start loading a page nsCOMPtr<nsIWebBrowser> newBrowser; chrome->GetWebBrowser(getter_AddRefs(newBrowser)); nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(newBrowser)); return webNav->LoadURI(NS_ConvertASCIItoUCS2(url).get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull); } return rv; }
void nsCSSScanner::OutputError() { if (mError.IsEmpty()) return; #ifdef DEBUG fprintf(stderr, "CSS Error (%s :%u.%u): %s\n", mFileName.get(), mErrorLineNumber, mErrorColNumber, NS_ConvertUCS2toUTF8(mError).get()); #endif // Log it to the Error console if (InitGlobals() && gReportErrors) { nsresult rv; nsCOMPtr<nsIScriptError> errorObject = do_CreateInstance(gScriptErrorFactory, &rv); if (NS_SUCCEEDED(rv)) { rv = errorObject->Init(mError.get(), NS_ConvertASCIItoUCS2(mFileName.get()).get(), EmptyString().get(), mErrorLineNumber, mErrorColNumber, nsIScriptError::warningFlag, "CSS Parser"); if (NS_SUCCEEDED(rv)) gConsoleService->LogMessage(errorObject); } } ClearError(); }
// Only used in really bad situations! static void _PanicErrorWrite(const char *msg) { nsCOMPtr<nsIConsoleService> consoleService = do_GetService(NS_CONSOLESERVICE_CONTRACTID); if (consoleService) consoleService->LogStringMessage(NS_ConvertASCIItoUCS2(msg).get()); PR_fprintf(PR_STDERR,"%s\n", msg); }
NS_INTERFACE_MAP_END void nsMyListener::Start(const char *arg2) { nsresult rv; nsCOMPtr<nsIDOMDocument> doc(do_CreateInstance( kXMLDocumentCID, &rv )); if (NS_SUCCEEDED( rv )) { nsCOMPtr<nsIDOMEventTarget> pDOMEventTarget = do_QueryInterface( doc, &rv ); if (NS_SUCCEEDED( rv )) { nsCOMPtr<nsIDOMEventListener> pDOMEventListener = do_QueryInterface( this, &rv ); if (NS_SUCCEEDED( rv )) { nsAutoString sLoadCommand; sLoadCommand.Assign( NS_LITERAL_STRING("load") ); rv = pDOMEventTarget->AddEventListener( sLoadCommand, pDOMEventListener, PR_FALSE ); if (NS_SUCCEEDED( rv )) { nsCOMPtr<nsIDOMNSDocument> pDOMNSDocument = do_QueryInterface( doc, &rv ); if (NS_SUCCEEDED( rv )) { rv = pDOMNSDocument->Load( NS_ConvertASCIItoUCS2(arg2) ); } } } } } }
void CTests::OnToolsViewLogfile() { char theURI[1024]; CStdioFile myFile; CFileException e; CString strFileName = "c:\\temp\\TestOutput.txt"; myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite | CStdioFile::modeNoTruncate, &e ); myFile.Close(); strcpy(theURI, "file://C|/temp/TestOutput.txt"); rv = qaWebNav->LoadURI(NS_ConvertASCIItoUCS2(theURI).get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull,nsnull, nsnull); }
void CTests::OnTestsChangeUrl() { if (!qaWebNav) { QAOutput("Web navigation object not found. Change URL test not performed.", 2); return; } if (myDialog.DoModal() == IDOK) { QAOutput("Begin Change URL test.", 1); rv = qaWebNav->LoadURI(NS_ConvertASCIItoUCS2(myDialog.m_urlfield).get(), myDialog.m_flagvalue, nsnull,nsnull, nsnull); RvTestResult(rv, "rv LoadURI() test", 1); FormatAndPrintOutput("The url = ", myDialog.m_urlfield, 2); FormatAndPrintOutput("The flag = ", myDialog.m_flagvalue, 1); QAOutput("End Change URL test.", 1); } else QAOutput("Change URL test not executed.", 1); }
/** * Transform a XML document given by path with the given * stylesheet. */ nsresult txStandaloneXSLTProcessor::transform(nsACString& aXMLPath, nsACString& aXSLPath, ostream& aOut, ErrorObserver& aErr) { txXPathNode* xmlDoc = parsePath(aXMLPath, aErr); if (!xmlDoc) { return NS_ERROR_FAILURE; } txParsedURL path; path.init(NS_ConvertASCIItoUCS2(aXSLPath)); nsRefPtr<txStylesheet> style; nsresult rv = TX_CompileStylesheetPath(path, getter_AddRefs(style)); if (NS_FAILED(rv)) { delete xmlDoc; return rv; } // transform rv = transform(*xmlDoc, style, aOut, aErr); delete xmlDoc; return rv; }
// // FUNCTION: BrowserDlgProc() // // PURPOSE: Browser dialog windows message handler. // // COMMENTS: // // The code for handling buttons and menu actions is here. // BOOL CALLBACK BrowserDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { // Get the browser and other pointers since they are used a lot below HWND hwndBrowser = GetDlgItem(hwndDlg, IDC_BROWSER); nsIWebBrowserChrome *chrome = nsnull ; if (hwndBrowser) { chrome = (nsIWebBrowserChrome *) GetWindowLong(hwndBrowser, GWL_USERDATA); } nsCOMPtr<nsIWebBrowser> webBrowser; nsCOMPtr<nsIWebNavigation> webNavigation; nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint; if (chrome) { chrome->GetWebBrowser(getter_AddRefs(webBrowser)); webNavigation = do_QueryInterface(webBrowser); webBrowserPrint = do_GetInterface(webBrowser); } // Test the message switch (uMsg) { case WM_INITDIALOG: return TRUE; case WM_INITMENU: UpdateUI(chrome); return TRUE; case WM_SYSCOMMAND: if (wParam == SC_CLOSE) { WebBrowserChromeUI::Destroy(chrome); return TRUE; } break; case WM_DESTROY: return TRUE; case WM_COMMAND: if (!webBrowser) { return TRUE; } // Test which command was selected switch (LOWORD(wParam)) { case IDC_ADDRESS: if (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE) { // User has changed the address field so enable the Go button EnableWindow(GetDlgItem(hwndDlg, IDC_GO), TRUE); } break; case IDC_GO: { TCHAR szURL[2048]; memset(szURL, 0, sizeof(szURL)); GetDlgItemText(hwndDlg, IDC_ADDRESS, szURL, sizeof(szURL) / sizeof(szURL[0]) - 1); webNavigation->LoadURI( NS_ConvertASCIItoUCS2(szURL).get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull); } break; case IDC_STOP: webNavigation->Stop(nsIWebNavigation::STOP_ALL); UpdateUI(chrome); break; case IDC_RELOAD: webNavigation->Reload(nsIWebNavigation::LOAD_FLAGS_NONE); break; case IDM_EXIT: PostMessage(hwndDlg, WM_SYSCOMMAND, SC_CLOSE, 0); break; // File menu commands case MOZ_NewBrowser: OpenWebPage(gFirstURL); break; case MOZ_Save: SaveWebPage(webBrowser); break; case MOZ_Print: { // NOTE: Embedding code shouldn't need to get the docshell or // contentviewer AT ALL. This code below will break one // day but will have to do until the embedding API has // a cleaner way to do the same thing. if (webBrowserPrint) { nsCOMPtr<nsIPrintSettings> printSettings; webBrowserPrint->GetGlobalPrintSettings(getter_AddRefs(printSettings)); NS_ASSERTION(printSettings, "You can't PrintPreview without a PrintSettings!"); if (printSettings) { printSettings->SetPrintSilent(PR_TRUE); webBrowserPrint->Print(printSettings, (nsIWebProgressListener*)nsnull); } } } break; // Edit menu commands case MOZ_Cut: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->CutSelection(); } break; case MOZ_Copy: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->CopySelection(); } break; case MOZ_Paste: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->Paste(); } break; case MOZ_SelectAll: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->SelectAll(); } break; case MOZ_SelectNone: { nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(webBrowser); clipCmds->SelectNone(); } break; // Go menu commands case IDC_BACK: case MOZ_GoBack: webNavigation->GoBack(); UpdateUI(chrome); break; case IDC_FORWARD: case MOZ_GoForward: webNavigation->GoForward(); UpdateUI(chrome); break; // Help menu commands case MOZ_About: { TCHAR szAboutTitle[MAX_LOADSTRING]; TCHAR szAbout[MAX_LOADSTRING]; LoadString(ghInstanceResources, IDS_ABOUT_TITLE, szAboutTitle, MAX_LOADSTRING); LoadString(ghInstanceResources, IDS_ABOUT, szAbout, MAX_LOADSTRING); MessageBox(NULL, szAbout, szAboutTitle, MB_OK); } break; } return TRUE; case WM_ACTIVATE: { nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(webBrowser)); if(focus) { switch (wParam) { case WA_ACTIVE: focus->Activate(); break; case WA_INACTIVE: focus->Deactivate(); break; default: break; } } } break; case WM_SIZE: { UINT newDlgWidth = LOWORD(lParam); UINT newDlgHeight = HIWORD(lParam); // TODO Reposition the control bar - for the moment it's fixed size // Reposition the status area. Status bar // gets any space that the fixed size progress bar doesn't use. int progressWidth; int statusWidth; int statusHeight; HWND hwndStatus = GetDlgItem(hwndDlg, IDC_STATUS); if (hwndStatus) { RECT rcStatus; GetWindowRect(hwndStatus, &rcStatus); statusHeight = rcStatus.bottom - rcStatus.top; } else statusHeight = 0; HWND hwndProgress = GetDlgItem(hwndDlg, IDC_PROGRESS); if (hwndProgress) { RECT rcProgress; GetWindowRect(hwndProgress, &rcProgress); progressWidth = rcProgress.right - rcProgress.left; } else progressWidth = 0; statusWidth = newDlgWidth - progressWidth; if (hwndStatus) SetWindowPos(hwndStatus, HWND_TOP, 0, newDlgHeight - statusHeight, statusWidth, statusHeight, SWP_NOZORDER); if (hwndProgress) SetWindowPos(hwndProgress, HWND_TOP, statusWidth, newDlgHeight - statusHeight, 0, 0, SWP_NOSIZE | SWP_NOZORDER); // Resize the browser area (assuming the browse is // sandwiched between the control bar and status area) RECT rcBrowser; POINT ptBrowser; GetWindowRect(hwndBrowser, &rcBrowser); ptBrowser.x = rcBrowser.left; ptBrowser.y = rcBrowser.top; ScreenToClient(hwndDlg, &ptBrowser); int browserHeight = newDlgHeight - ptBrowser.y - statusHeight; if (browserHeight < 1) { browserHeight = 1; } SetWindowPos(hwndBrowser, HWND_TOP, 0, 0, newDlgWidth, newDlgHeight - ptBrowser.y - statusHeight, SWP_NOMOVE | SWP_NOZORDER); } return TRUE; } return FALSE; }
/* static */ PRInt32 nsMathMLFrame::MapAttributesIntoCSS(nsPresContext* aPresContext, nsIContent* aContent) { // normal case, quick return if there are no attributes NS_ASSERTION(aContent, "null arg"); PRUint32 attrCount = 0; if (aContent) attrCount = aContent->GetAttrCount(); if (!attrCount) return 0; // need to initialize here -- i.e., after registering nsMathMLAtoms static const nsCSSMapping kCSSMappingTable[] = { {kMathMLversion2, nsMathMLAtoms::mathcolor_, "color:"}, {kMathMLversion1, nsMathMLAtoms::color_, "color:"}, {kMathMLversion2, nsMathMLAtoms::mathsize_, "font-size:"}, {kMathMLversion1, nsMathMLAtoms::fontsize_, "font-size:"}, {kMathMLversion1, nsMathMLAtoms::fontfamily_, "font-family:"}, {kMathMLversion2, nsMathMLAtoms::mathbackground_, "background-color:"}, {kMathMLversion1, nsMathMLAtoms::background_, "background-color:"}, {0, nsnull, nsnull} }; nsCOMPtr<nsIDocument> doc; nsCOMPtr<nsIStyleSheet> sheet; nsCOMPtr<nsICSSStyleSheet> cssSheet; nsCOMPtr<nsIDOMCSSStyleSheet> domSheet; PRInt32 nameSpaceID; nsCOMPtr<nsIAtom> prefix; nsCOMPtr<nsIAtom> attrAtom; PRInt32 ruleCount = 0; for (PRUint32 i = 0; i < attrCount; ++i) { aContent->GetAttrNameAt(i, &nameSpaceID, getter_AddRefs(attrAtom), getter_AddRefs(prefix)); // lookup the equivalent CSS property const nsCSSMapping* map = kCSSMappingTable; while (map->attrAtom && map->attrAtom != attrAtom) ++map; if (!map->attrAtom) continue; nsAutoString cssProperty(NS_ConvertASCIItoUCS2(map->cssProperty)); nsAutoString attrValue; aContent->GetAttr(nameSpaceID, attrAtom, attrValue); if (attrValue.IsEmpty()) continue; nsAutoString escapedAttrValue; nsStyleUtil::EscapeCSSString(attrValue, escapedAttrValue); // don't add rules that are already in mathml.css // (this will also clean up whitespace before units - see bug 125303) if (attrAtom == nsMathMLAtoms::fontsize_ || attrAtom == nsMathMLAtoms::mathsize_) { nsCSSValue cssValue; nsAutoString numericValue(attrValue); if (!ParseNumericValue(numericValue, cssValue)) continue; // on exit, ParseNumericValue also returns a nicer string // in which the whitespace before the unit is cleaned up cssProperty.Append(numericValue); } else cssProperty.Append(attrValue); nsAutoString attrName; attrAtom->ToString(attrName); // make a style rule that maps to the equivalent CSS property nsAutoString cssRule; cssRule.Assign(NS_LITERAL_STRING("[") + attrName + NS_LITERAL_STRING("='") + escapedAttrValue + NS_LITERAL_STRING("']{") + cssProperty + NS_LITERAL_STRING("}")); if (!sheet) { // first time... we do this to defer the lookup up to the // point where we encounter attributes that actually matter doc = aContent->GetDocument(); if (!doc) return 0; GetMathMLAttributeStyleSheet(aPresContext, getter_AddRefs(sheet)); if (!sheet) return 0; // by construction, these cannot be null at this point cssSheet = do_QueryInterface(sheet); domSheet = do_QueryInterface(sheet); NS_ASSERTION(cssSheet && domSheet, "unexpected null pointers"); // we will keep the sheet orphan as we populate it. This way, // observers of the document won't be notified and we avoid any troubles // that may come from reconstructing the frame tree. Our rules only need // a re-resolve of style data and a reflow, not a reconstruct-all... sheet->SetOwningDocument(nsnull); } // check for duplicate, if a similar rule is already there, don't bother to add another one nsAutoString selector; selector.Assign(NS_LITERAL_STRING("*[") + attrName + NS_LITERAL_STRING("=\"") + escapedAttrValue + NS_LITERAL_STRING("\"]")); PRInt32 k, count; cssSheet->StyleRuleCount(count); for (k = 0; k < count; ++k) { nsAutoString tmpSelector; nsCOMPtr<nsICSSRule> tmpRule; cssSheet->GetStyleRuleAt(k, *getter_AddRefs(tmpRule)); nsCOMPtr<nsICSSStyleRule> tmpStyleRule = do_QueryInterface(tmpRule); if (tmpStyleRule) { tmpStyleRule->GetSelectorText(tmpSelector); if (tmpSelector.Equals(selector)) { k = -1; break; } } } if (k >= 0) { // insert the rule (note: when the sheet already has @namespace and // friends, insert after them, e.g., at the end, otherwise it won't work) // For MathML 2, insert at the end to give it precedence PRInt32 pos = (map->compatibility == kMathMLversion2) ? count : 1; PRUint32 index; domSheet->InsertRule(cssRule, pos, &index); ++ruleCount; } } // restore the sheet to its owner if (sheet) { sheet->SetOwningDocument(doc); } return ruleCount; }
static nsString* ConvertCharacterSetName(const char* aName) { return new nsString(NS_ConvertASCIItoUCS2(aName)); }
NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *aAddress, PRBool aCreateCard, PRUint32 aSendFormat) { // note that we're now setting the whole recipient list, // not just the pretty name of the first recipient. PRUint32 numAddresses; char *names; char *addresses; nsresult rv; nsCOMPtr<nsIMsgHeaderParser> pHeader = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv,rv); rv = pHeader->ParseHeaderAddresses(nsnull, aAddress, &names, &addresses, &numAddresses); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to parse, so can't collect"); if (NS_FAILED(rv)) return NS_OK; char *curName = names; char *curAddress = addresses; for (PRUint32 i = 0; i < numAddresses; i++) { nsXPIDLCString unquotedName; rv = pHeader->UnquotePhraseOrAddr(curName, PR_FALSE, getter_Copies(unquotedName)); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to unquote name"); if (NS_FAILED(rv)) continue; nsCOMPtr <nsIAbCard> existingCard; nsCOMPtr <nsIAbCard> cardInstance; PRBool emailAddressIn2ndEmailColumn = PR_FALSE; rv = GetCardFromAttribute(kPriEmailColumn, curAddress, getter_AddRefs(existingCard)); // We've not found a card, but is this address actually in the additional // email column? if (!existingCard) { rv = GetCardFromAttribute(k2ndEmailColumn, curAddress, getter_AddRefs(existingCard)); if (existingCard) emailAddressIn2ndEmailColumn = PR_TRUE; } if (!existingCard && aCreateCard) { nsCOMPtr<nsIAbCard> senderCard = do_CreateInstance(NS_ABCARDPROPERTY_CONTRACTID, &rv); if (NS_SUCCEEDED(rv) && senderCard) { PRBool modifiedCard; rv = SetNamesForCard(senderCard, unquotedName.get(), &modifiedCard); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to set names"); rv = AutoCollectScreenName(senderCard, curAddress, &modifiedCard); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to set screenname"); rv = senderCard->SetPrimaryEmail(NS_ConvertASCIItoUCS2(curAddress).get()); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to set email"); if (aSendFormat != nsIAbPreferMailFormat::unknown) { rv = senderCard->SetPreferMailFormat(aSendFormat); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to remember preferred mail format"); } rv = AddCardToAddressBook(senderCard); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to add card"); } } else if (existingCard && !emailAddressIn2ndEmailColumn) { // address is already in the AB, so update the names PRBool setNames = PR_FALSE; if (!unquotedName.IsEmpty()) { rv = SetNamesForCard(existingCard, unquotedName.get(), &setNames); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to set names"); } PRBool setScreenName = PR_FALSE; rv = AutoCollectScreenName(existingCard, curAddress, &setScreenName); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to set screen name"); PRBool setPreferMailFormat = PR_FALSE; if (aSendFormat != nsIAbPreferMailFormat::unknown) { PRUint32 currentFormat; rv = existingCard->GetPreferMailFormat(¤tFormat); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get preferred mail format"); // we only want to update the AB if the current format is unknown if (currentFormat == nsIAbPreferMailFormat::unknown) { rv = existingCard->SetPreferMailFormat(aSendFormat); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to remember preferred mail format"); setPreferMailFormat = PR_TRUE; } } if (setScreenName || setNames || setPreferMailFormat) existingCard->EditCardToDatabase(m_abURI.get()); } curName += strlen(curName) + 1; curAddress += strlen(curAddress) + 1; } PR_FREEIF(addresses); PR_FREEIF(names); return NS_OK; }