// end of all arcs coming out of msgaccounts:/ nsresult nsMsgAccountManagerDataSource::createRootResources(nsIRDFResource *property, nsCOMArray<nsIRDFResource> *aNodeArray) { nsresult rv = NS_OK; if (isContainment(property)) { nsCOMPtr<nsIMsgAccountManager> am = do_QueryReferent(mAccountManager); if (!am) return NS_ERROR_FAILURE; nsCOMPtr<nsIArray> servers; rv = am->GetAllServers(getter_AddRefs(servers)); NS_ENSURE_SUCCESS(rv, rv); uint32_t length; rv = servers->GetLength(&length); NS_ENSURE_SUCCESS(rv, rv); for (uint32_t i = 0; i < length; ++i) { nsCOMPtr<nsIMsgIncomingServer> server(do_QueryElementAt(servers, i, &rv)); if (NS_FAILED(rv)) continue; nsCOMPtr<nsIMsgFolder> serverFolder; rv = server->GetRootFolder(getter_AddRefs(serverFolder)); if (NS_FAILED(rv)) continue; // add the resource to the array nsCOMPtr<nsIRDFResource> serverResource = do_QueryInterface(serverFolder); if (serverResource) (void) aNodeArray->AppendObject(serverResource); } #ifdef DEBUG_amds uint32_t nodecount; aNodeArray->GetLength(&nodecount); printf("GetTargets(): added %d servers on %s\n", nodecount, (const char*)property_arc); #endif // For the "settings" arc, we also want to add SMTP setting. if (property == kNC_Settings) { aNodeArray->AppendObject(kNC_PageTitleSMTP); } } #ifdef DEBUG_amds else { printf("unknown arc %s on msgaccounts:/\n", (const char*)property_arc); } #endif return rv; }
nsresult nsMsgAccountManagerDataSource::HasAssertionAccountRoot(nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, bool *_retval) { // set up default *_retval = false; // for child and settings arcs, just make sure it's a valid server: if (isContainment(aProperty)) { nsCOMPtr<nsIMsgIncomingServer> server; nsresult rv = getServerForFolderNode(aTarget, getter_AddRefs(server)); if (NS_FAILED(rv) || !server) return rv; nsCString serverKey; server->GetKey(serverKey); nsCOMPtr<nsIMsgAccountManager> am = do_QueryReferent(mAccountManager, &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIArray> serverArray; rv = am->GetAllServers(getter_AddRefs(serverArray)); NS_ENSURE_SUCCESS(rv, rv); uint32_t length; rv = serverArray->GetLength(&length); NS_ENSURE_SUCCESS(rv, rv); for (uint32_t i = 0; i < length; ++i) { nsCOMPtr<nsIMsgIncomingServer> server(do_QueryElementAt(serverArray, i, &rv)); if (NS_FAILED(rv)) continue; nsCString key; server->GetKey(key); if (key.Equals(serverKey)) { *_retval = true; break; } } } return NS_OK; }
// end of all arcs coming out of msgaccounts:/ nsresult nsMsgAccountManagerDataSource::createRootResources(nsIRDFResource *property, nsISupportsArray* aNodeArray) { nsresult rv = NS_OK; if (isContainment(property)) { nsCOMPtr<nsIMsgAccountManager> am = do_QueryReferent(mAccountManager); if (!am) return NS_ERROR_FAILURE; nsCOMPtr<nsISupportsArray> servers; rv = am->GetAllServers(getter_AddRefs(servers)); if (NS_FAILED(rv)) return rv; // fill up the nodes array with the RDF Resources for the servers serverCreationParams params = { aNodeArray, getRDFService() }; servers->EnumerateForwards(createServerResources, (void*)¶ms); #ifdef DEBUG_amds PRUint32 nodecount; aNodeArray->Count(&nodecount); printf("GetTargets(): added %d servers on %s\n", nodecount, (const char*)property_arc); #endif // for the "settings" arc, we also want to add SMTP setting and the fake account (if required) if (property == kNC_Settings) { aNodeArray->AppendElement(kNC_PageTitleSMTP); if (IsFakeAccountRequired()) aNodeArray->AppendElement(kNC_PageTitleFakeAccount); } else if (property == kNC_Child && IsFakeAccountRequired()) { aNodeArray->AppendElement(kNC_PageTitleFakeAccount); } } #ifdef DEBUG_amds else { printf("unknown arc %s on msgaccounts:/\n", (const char*)property_arc); } #endif return rv; }
nsresult nsMsgAccountManagerDataSource::HasAssertionAccountRoot(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, PRBool *_retval) { nsresult rv; // set up default *_retval = PR_FALSE; // for child and settings arcs, just make sure it's a valid server: if (isContainment(aProperty)) { nsCOMPtr<nsIMsgIncomingServer> server; rv = getServerForFolderNode(aTarget, getter_AddRefs(server)); if (NS_FAILED(rv) || !server) return rv; nsXPIDLCString serverKey; server->GetKey(getter_Copies(serverKey)); nsCOMPtr<nsIMsgAccountManager> am = do_QueryReferent(mAccountManager, &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsISupportsArray> serverArray; rv = am->GetAllServers(getter_AddRefs(serverArray)); if (NS_FAILED(rv)) return rv; findServerByKeyEntry entry; entry.serverKey = serverKey; entry.found = PR_FALSE; serverArray->EnumerateForwards(findServerByKey, &entry); (*_retval) = entry.found; } return NS_OK; }
bool Match::isSubstringContainment() const { return isContainment() && (!coord[0].isContained() || !coord[1].isContained()); }