PRBool nsMAPIConfiguration::UnRegisterSession(PRUint32 aSessionID) { PRBool bResult = PR_FALSE; PR_Lock(m_Lock); if (aSessionID != 0) { nsPRUintKey sessionKey(aSessionID); nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey); if (pTemp != nsnull) { if (pTemp->DecrementSession() == 0) { if (pTemp->m_pProfileName.get() != nsnull) { nsStringKey stringKey(pTemp->m_pProfileName.get()); m_ProfileMap.Remove(&stringKey); } m_SessionMap.Remove(&sessionKey); sessionCount--; bResult = PR_TRUE; } } } PR_Unlock(m_Lock); return bResult; }
Vector<String> Dictionary::getPropertyNames( ExceptionState& exceptionState) const { if (m_dictionaryObject.IsEmpty()) return Vector<String>(); v8::TryCatch tryCatch(isolate()); v8::Local<v8::Array> propertyNames; if (!m_dictionaryObject->GetPropertyNames(v8Context()) .ToLocal(&propertyNames)) { exceptionState.rethrowV8Exception(tryCatch.Exception()); return Vector<String>(); } Vector<String> names; for (uint32_t i = 0; i < propertyNames->Length(); ++i) { v8::Local<v8::String> key; if (!getStringValueInArray(v8Context(), propertyNames, i).ToLocal(&key)) { exceptionState.rethrowV8Exception(tryCatch.Exception()); return Vector<String>(); } V8StringResource<> stringKey(key); if (!stringKey.prepare(isolate(), exceptionState)) return Vector<String>(); names.push_back(stringKey); } return names; }
MSHashEntry::~MSHashEntry(void) { if (next()!=0) next()->_prev=prev(); if (prev()!=0) prev()->_next=next(); if (stringKey()!=0) delete [] _stringKey; _stringKey=0,_value=0,_key=0,_next=0,_prev=0; }
HashMap<String, String> Dictionary::getOwnPropertiesAsStringHashMap( ExceptionState& exceptionState) const { if (m_dictionaryObject.IsEmpty()) return HashMap<String, String>(); v8::TryCatch tryCatch(isolate()); v8::Local<v8::Array> propertyNames; if (!m_dictionaryObject->GetOwnPropertyNames(v8Context()) .ToLocal(&propertyNames)) { exceptionState.rethrowV8Exception(tryCatch.Exception()); return HashMap<String, String>(); } HashMap<String, String> ownProperties; for (uint32_t i = 0; i < propertyNames->Length(); ++i) { v8::Local<v8::String> key; if (!getStringValueInArray(v8Context(), propertyNames, i).ToLocal(&key)) { exceptionState.rethrowV8Exception(tryCatch.Exception()); return HashMap<String, String>(); } V8StringResource<> stringKey(key); if (!stringKey.prepare(isolate(), exceptionState)) return HashMap<String, String>(); v8::Local<v8::Value> value; if (!m_dictionaryObject->Get(v8Context(), key).ToLocal(&value)) { exceptionState.rethrowV8Exception(tryCatch.Exception()); return HashMap<String, String>(); } V8StringResource<> stringValue(value); if (!stringValue.prepare(isolate(), exceptionState)) return HashMap<String, String>(); if (!static_cast<const String&>(stringKey).isEmpty()) ownProperties.set(stringKey, stringValue); } return ownProperties; }
NS_IMETHODIMP sbLocalDatabaseMediaListBase::GetName(nsAString& aName) { nsAutoString unlocalizedName; nsresult rv = GetProperty(NS_LITERAL_STRING(SB_PROPERTY_MEDIALISTNAME), unlocalizedName); NS_ENSURE_SUCCESS(rv, rv); // If the property doesn't exist just return an empty string. if (unlocalizedName.IsEmpty()) { aName.Assign(unlocalizedName); return NS_OK; } // See if this string should be localized. The basic format we're looking for // is: // // &[chrome://songbird/songbird.properties#]library.name // // The url (followed by '#') is optional. const PRUnichar *start, *end; PRUint32 length = unlocalizedName.BeginReading(&start, &end); static const PRUnichar sAmp = '&'; // Bail out if this can't be a localizable string. if (length <= 1 || *start != sAmp) { aName.Assign(unlocalizedName); return NS_OK; } // Skip the ampersand start++; nsDependentSubstring stringKey(start, end - start), propertiesURL; static const PRUnichar sHash = '#'; for (const PRUnichar* current = start; current < end; current++) { if (*current == sHash) { stringKey.Rebind(current + 1, end - current - 1); propertiesURL.Rebind(start, current - start); break; } } nsCOMPtr<nsIStringBundleService> bundleService = do_GetService("@mozilla.org/intl/stringbundle;1", &rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIStringBundle> bundle; if (!propertiesURL.IsEmpty()) { nsCOMPtr<nsIURI> propertiesURI; rv = NS_NewURI(getter_AddRefs(propertiesURI), propertiesURL); if (NS_SUCCEEDED(rv)) { PRBool schemeIsChrome; rv = propertiesURI->SchemeIs("chrome", &schemeIsChrome); if (NS_SUCCEEDED(rv) && schemeIsChrome) { nsCAutoString propertiesSpec; rv = propertiesURI->GetSpec(propertiesSpec); if (NS_SUCCEEDED(rv)) { rv = bundleService->CreateBundle(propertiesSpec.get(), getter_AddRefs(bundle)); } } } } if (!bundle) { rv = bundleService->CreateBundle(DEFAULT_PROPERTIES_URL, getter_AddRefs(bundle)); } if (NS_SUCCEEDED(rv)) { nsAutoString localizedName; rv = bundle->GetStringFromName(stringKey.BeginReading(), getter_Copies(localizedName)); if (NS_SUCCEEDED(rv)) { aName.Assign(localizedName); return NS_OK; } } aName.Assign(unlocalizedName); return NS_OK; }