PRUnichar *nsEudoraStringBundle::GetStringByID(int32_t stringID) { if (!m_pBundle) m_pBundle = GetStringBundle(); if (m_pBundle) { PRUnichar *ptrv = nullptr; nsresult rv = m_pBundle->GetStringFromID(stringID, &ptrv); if (NS_SUCCEEDED(rv) && ptrv) return ptrv; } nsString resultString(NS_LITERAL_STRING("[StringID ")); resultString.AppendInt(stringID); resultString.AppendLiteral("?]"); return ToNewUnicode(resultString); }
PRUnichar *nsEudoraStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle *pBundle) { if (!pBundle) pBundle = GetStringBundle(); if (pBundle) { PRUnichar *ptrv = nsnull; nsresult rv = pBundle->GetStringFromID(stringID, &ptrv); if (NS_SUCCEEDED( rv) && ptrv) return( ptrv); } nsString resultString(NS_LITERAL_STRING("[StringID ")); resultString.AppendInt(stringID); resultString.AppendLiteral("?]"); return ToNewUnicode(resultString); }
PRUnichar *nsOEStringBundle::GetStringByID(PRInt32 stringID) { if (!m_pBundle) m_pBundle = GetStringBundle(); if (m_pBundle) { PRUnichar *ptrv = nsnull; nsresult rv = m_pBundle->GetStringFromID(stringID, &ptrv); if (NS_SUCCEEDED( rv) && ptrv) return( ptrv); } nsString resultString; resultString.AppendLiteral("[StringID "); resultString.AppendInt(stringID); resultString.AppendLiteral("?]"); return( ToNewUnicode(resultString)); }
char16_t *nsOEStringBundle::GetStringByID(int32_t stringID) { if (!m_pBundle) m_pBundle = GetStringBundle(); if (m_pBundle) { char16_t *ptrv = nullptr; nsresult rv = m_pBundle->GetStringFromID(stringID, &ptrv); if (NS_SUCCEEDED(rv) && ptrv) return ptrv; } nsString resultString; resultString.AppendLiteral("[StringID "); resultString.AppendInt(stringID); resultString.AppendLiteral("?]"); return ToNewUnicode(resultString); }
void nsMessengerUnixIntegration::FillToolTipInfo() { nsresult rv; nsCString folderUri; GetFirstFolderWithNewMail(folderUri); uint32_t count = 0; if (NS_FAILED(mFoldersWithNewMail->Count(&count))) return; nsCOMPtr<nsIWeakReference> weakReference; nsCOMPtr<nsIMsgFolder> folder = nullptr; nsCOMPtr<nsIMsgFolder> folderWithNewMail = nullptr; uint32_t i; for (i = 0; i < count && !folderWithNewMail; i++) { weakReference = do_QueryElementAt(mFoldersWithNewMail, i); folder = do_QueryReferent(weakReference); folder->GetChildWithURI(folderUri, true, true, getter_AddRefs(folderWithNewMail)); } if (folder && folderWithNewMail) { #ifdef MOZ_THUNDERBIRD nsCOMPtr<nsIStringBundle> bundle; GetStringBundle(getter_AddRefs(bundle)); if (!bundle) return; // Create the notification title nsString alertTitle; if (!BuildNotificationTitle(folder, bundle, alertTitle)) return; // Let's get the new mail for this folder nsCOMPtr<nsIMsgDatabase> db; if (NS_FAILED(folderWithNewMail->GetMsgDatabase(getter_AddRefs(db)))) return; uint32_t numNewKeys = 0; uint32_t *newMessageKeys; db->GetNewList(&numNewKeys, &newMessageKeys); // If we had new messages, we *should* have new keys, but we'll // check just in case. if (numNewKeys <= 0) { NS_Free(newMessageKeys); return; } // Find the rootFolder that folder belongs to, and find out // what MRUTime it maps to. Assign this to lastMRUTime. uint32_t lastMRUTime = 0; if (NS_FAILED(GetMRUTimestampForFolder(folder, &lastMRUTime))) lastMRUTime = 0; // Next, add the new message headers to an nsCOMArray. We // only add message headers that are newer than lastMRUTime. nsCOMArray<nsIMsgDBHdr> newMsgHdrs; for (unsigned int i = 0; i < numNewKeys; ++i) { nsCOMPtr<nsIMsgDBHdr> hdr; if (NS_FAILED(db->GetMsgHdrForKey(newMessageKeys[i], getter_AddRefs(hdr)))) continue; uint32_t dateInSeconds = 0; hdr->GetDateInSeconds(&dateInSeconds); if (dateInSeconds > lastMRUTime) newMsgHdrs.AppendObject(hdr); } // At this point, we don't need newMessageKeys any more, // so let's free it. NS_Free(newMessageKeys); // If we didn't happen to add any message headers, bail out if (!newMsgHdrs.Count()) return; // Sort the message headers by dateInSeconds, in ascending // order newMsgHdrs.Sort(nsMsgDbHdrTimestampComparator, nullptr); nsString alertBody; // Build the body text of the notification. if (!BuildNotificationBody(newMsgHdrs[0], bundle, alertBody)) return; // Show the notification ShowAlertMessage(alertTitle, alertBody, EmptyCString()); // Find the last, and therefore newest message header // in our nsCOMArray nsCOMPtr<nsIMsgDBHdr> lastMsgHdr = newMsgHdrs[newMsgHdrs.Count() - 1]; uint32_t dateInSeconds = 0; if (NS_FAILED(lastMsgHdr->GetDateInSeconds(&dateInSeconds))) return; // Write the newest message timestamp to the appropriate // mapping in our hashtable of MRUTime's. PutMRUTimestampForFolder(folder, dateInSeconds); #else nsString accountName; folder->GetPrettiestName(accountName); nsCOMPtr<nsIStringBundle> bundle; GetStringBundle(getter_AddRefs(bundle)); if (bundle) { int32_t numNewMessages = 0; folder->GetNumNewMessages(true, &numNewMessages); nsAutoString numNewMsgsText; numNewMsgsText.AppendInt(numNewMessages); const PRUnichar *formatStrings[] = { numNewMsgsText.get(), }; nsString finalText; if (numNewMessages == 1) bundle->FormatStringFromName(NS_LITERAL_STRING("biffNotification_message").get(), formatStrings, 1, getter_Copies(finalText)); else bundle->FormatStringFromName(NS_LITERAL_STRING("biffNotification_messages").get(), formatStrings, 1, getter_Copies(finalText)); ShowAlertMessage(accountName, finalText, EmptyCString()); } // if we got a bundle #endif } // if we got a folder }