std::list<CommandConstPtr> TextureWallSyncData::generateUpdateCommands() const { std::list<CommandConstPtr> updateCommands = ResourceSyncData::generateUpdateCommands(); std::map< TextureWallParameterName, const float* > textureWallParametersMap = { { TextureWallParameterName::TEXTURE_OFFSET_X, &textureWall_.textureOffset.x }, { TextureWallParameterName::TEXTURE_OFFSET_Y, &textureWall_.textureOffset.y }, { TextureWallParameterName::TEXTURE_SCALE_X, &textureWall_.textureScale.x }, { TextureWallParameterName::TEXTURE_SCALE_Y, &textureWall_.textureScale.y } }; for( const auto& textureWallParameter : textureWallParametersMap ){ updateCommands.push_back( CommandConstPtr( new TextureWallModificationCommand( resourceID(), NO_USER, textureWallParameter.first, *(textureWallParameter.second) ) ) ); } updateCommands.push_back( CommandConstPtr( new TextureWallTextureChangeCommand( resourceID(), NO_USER, textureWall_.textureID ) ) ); return updateCommands; }
void es_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx) { RDF_Resource parent = NULL, child = NULL, r; _esFEData *feData; char *newURL, *p; feData = (_esFEData *)urls->fe_data; if ((status >= 0) && (feData != NULL)) { parent = RDF_GetResource(gNCDB, feData->parent, false); child = RDF_GetResource(gNCDB, feData->child, false); if ((parent != NULL) && (child != NULL)) { switch(feData->method) { case URL_POST_METHOD: if (((p = strrchr(resourceID(child), '/')) != NULL) && (*++p != '\0')) { if ((newURL = append2Strings(resourceID(parent), p)) != NULL) { if ((r = RDF_GetResource(gNCDB, newURL, 1)) != NULL) { setContainerp(r, containerp(child)); setResourceType(r, resourceType(child)); remoteStoreAdd(gRemoteStore, r, gCoreVocab->RDF_parent, parent, RDF_RESOURCE_TYPE, 1); } freeMem(newURL); } } break; case URL_DELETE_METHOD: remoteStoreRemove(gRemoteStore, child, gCoreVocab->RDF_parent, parent, RDF_RESOURCE_TYPE); break; } } } else if (status < 0) { if ((cx != NULL) && (urls != NULL) && (urls->error_msg != NULL)) { FE_Alert(cx, urls->error_msg); } } if (feData != NULL) { esFreeFEData(feData); } NET_FreeURLStruct (urls); }
char * getRelURL (RDF_Resource u, RDF_Resource top) { char* uID = resourceID(u); char* topID = resourceID(top); if (startsWith(topID, uID)) { int16 n = charSearch('#', uID); if (n == -1) return uID; return &(uID)[n+1]; } else return uID; }
_esFEData * esMakeFEData(RDF_Resource parent, RDF_Resource child, int method) { _esFEData *feData; if ((feData = (_esFEData *)XP_ALLOC(3*sizeof(char *))) != NULL) { feData->parent = copyString(resourceID(parent)); feData->child = copyString(resourceID(child)); feData->method = method; } return(feData); }
void * ESGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) { if (!ESFTPRT(u)) return NULL; if ((s == gCoreVocab->RDF_name) && (type == RDF_STRING_TYPE) && (tv)) { char *pathname, *name = NULL; int16 n,len; if (pathname = copyString(resourceID(u))) { len = strlen(pathname); if (pathname[len-1] == '/') pathname[--len] = '\0'; n = revCharSearch('/', pathname); name = unescapeURL(&pathname[n+1]); freeMem(pathname); } return(name); } else if (u->rarg1 == NULL) possiblyAccessES(rdf, u, s, inversep); return null; }
already_AddRefed<nsIMetricsEventItem> nsProfileCollector::ExtensionEnumerator::CreateExtensionItem( nsIUpdateItem *extension) { nsCOMPtr<nsIMetricsEventItem> extensionItem; mMetricsService->CreateEventItem(NS_LITERAL_STRING("extension"), getter_AddRefs(extensionItem)); NS_ENSURE_TRUE(extensionItem, nsnull); nsCOMPtr<nsIWritablePropertyBag2> properties; nsMetricsUtils::NewPropertyBag(getter_AddRefs(properties)); NS_ENSURE_TRUE(properties, nsnull); nsString id, version; extension->GetId(id); NS_ENSURE_TRUE(!id.IsEmpty(), nsnull); nsCString hashedID; nsresult rv = mMetricsService->HashUTF16(id, hashedID); NS_ENSURE_SUCCESS(rv, nsnull); properties->SetPropertyAsACString( NS_LITERAL_STRING("extensionid"), hashedID); extension->GetVersion(version); if (!version.IsEmpty()) { properties->SetPropertyAsAString(NS_LITERAL_STRING("version"), version); } MS_LOG(("Logged extension extensionid=%s (hashed to %s) version=%s", NS_ConvertUTF16toUTF8(id).get(), hashedID.get(), NS_ConvertUTF16toUTF8(version).get())); nsCString resourceID("urn:mozilla:item:"); resourceID.Append(NS_ConvertUTF16toUTF8(id)); nsCOMPtr<nsIRDFResource> itemResource; mRDFService->GetResource(resourceID, getter_AddRefs(itemResource)); NS_ENSURE_TRUE(itemResource, nsnull); nsCOMPtr<nsIRDFNode> itemDisabledNode; mExtensionsDS->GetTarget(itemResource, mDisabledResource, PR_TRUE, getter_AddRefs(itemDisabledNode)); nsCOMPtr<nsIRDFLiteral> itemDisabledLiteral = do_QueryInterface(itemDisabledNode); if (itemDisabledLiteral) { const PRUnichar *value = nsnull; itemDisabledLiteral->GetValueConst(&value); if (nsDependentString(value).Equals(NS_LITERAL_STRING("true"))) { properties->SetPropertyAsBool(NS_LITERAL_STRING("disabled"), PR_TRUE); MS_LOG(("Logged extension disabled=true")); } } extensionItem->SetProperties(properties); nsIMetricsEventItem *item = nsnull; extensionItem.swap(item); return item; }
PRBool historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) { if ((type == RDF_RESOURCE_TYPE) && (resourceType((RDF_Resource)v) == HISTORY_RT) && (s == gCoreVocab->RDF_parent)) { RDF_Resource parents[5]; int8 n = 0; Assertion as = u->rarg1; memset(parents, '\0', 5 * sizeof(RDF_Resource)); while (as) { if ((as->type == RDF_RESOURCE_TYPE) && (as->s == gCoreVocab->RDF_parent) && (resourceType((RDF_Resource)as->value) == HISTORY_RT) && (n < 5)) { parents[n++] = (RDF_Resource)as->value; } as = as->next; } GH_DeleteHistoryItem ( resourceID(u)); while (n > 0) { n = n - 1; if (parents[n]) { Assertion nas = remoteStoreRemove (gRemoteStore, u, gCoreVocab->RDF_parent, parents[n], RDF_RESOURCE_TYPE); freeMem(nas); } } return 1; } return 0; }
Assertion histAddParent (RDF_Resource child, RDF_Resource parent) { Assertion nextAs, prevAs, newAs; RDF_Resource s = gCoreVocab->RDF_parent; RDF_ValueType type = RDF_RESOURCE_TYPE; nextAs = prevAs = child->rarg1; while (nextAs != null) { if (asEqual(nextAs, child, s, parent, type)) return null; prevAs = nextAs; nextAs = nextAs->next; } newAs = makeNewAssertion(child, s, parent, type, 1); if (prevAs == null) { child->rarg1 = newAs; } else { prevAs->next = newAs; } nextAs = prevAs = parent->rarg2; if (nextAs == NULL) { parent->rarg2 = newAs; } else { PRBool added = 0; while (nextAs != null) { char* nid = resourceID(nextAs->u); if (strcmp( resourceID(child), resourceID(nextAs->u)) > 0) { if (prevAs == nextAs) { newAs->invNext = prevAs; parent->rarg2 = newAs; added = 1; break; } else { newAs->invNext = nextAs; prevAs->invNext = newAs; added = 1; break; } } prevAs = nextAs; nextAs = nextAs->invNext; } if (!added) prevAs->invNext = newAs; } sendNotifications2(gHistoryStore, RDF_ASSERT_NOTIFY, child, s, parent, type, 1); /* XXX have to mark the entire subtree XXX */ /* sendNotifications(gRemoteStore->rdf, RDF_ASSERT_NOTIFY, child, s, parent, type, 1); */ }
void possiblyAccessES(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) { if ((ESFTPRT(u)) && (s == gCoreVocab->RDF_parent) && (containerp(u))) { char* id = resourceID(u); readRDFFile((resourceType(u) == ES_RT ? &id[4] : id), u, false); } }
char * makeResourceName (RDF_Resource node) { char* name; name = resourceID(node); if (startsWith("http:", name)) return copyString(&name[7]); if (startsWith("file:", name)) return copyString(&name[8]); return copyString(name); }
/** go tell the directory that child got added to parent **/ void ESAddChild (RDF_Resource parent, RDF_Resource child) { URL_Struct *urls; void *feData, **files_to_post = NULL; if ((urls = NET_CreateURLStruct(resourceID(parent), NET_SUPER_RELOAD)) != NULL) { feData = (void *)esMakeFEData(parent, child, URL_POST_METHOD); if ((files_to_post = (char **)XP_ALLOC(2*sizeof(char *))) != NULL) { files_to_post[0] = nativeFilename(resourceID(child)); files_to_post[1] = NULL; } if ((feData != NULL) && (files_to_post != NULL)) { urls->files_to_post = (void *)files_to_post; urls->post_to = NULL; urls->method = URL_POST_METHOD; urls->fe_data = (void *)feData; NET_GetURL(urls, FO_PRESENT, (MWContext *)gRDFMWContext(), es_GetUrlExitFunc); } else { if (feData != NULL) { esFreeFEData(feData); } if (files_to_post != NULL) { if (files_to_post[0] != NULL) freeMem(files_to_post[0]); XP_FREE(files_to_post); } NET_FreeURLStruct(urls); } } }
PRBool pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) { XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v))); if ((startsWith("mailbox://", rdf->url)) && (resourceType(u) == PM_RT) && (s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE)) { RDF_Resource mbox = (RDF_Resource) v; if (!(containerp(mbox) && (resourceType(mbox) == PM_RT))) { return false; } else { MF folder = (MF)mbox->pdata; sendNotifications2(rdf, RDF_DELETE_NOTIFY, u, s, v, type, 1); MoveMessage(folder->trash, resourceID(mbox), (MM)u->pdata); return 1; } } else return false; }
RDF_Resource hostUnitOfURL (RDF r, RDF_Resource top, RDF_Resource nu, char* title) { char host[100]; char* url = resourceID(nu); int16 s1, s2, s3; RDF_Resource hostResource, existing; if (strlen(url) > 100) return NULL; if (startsWith("file", url)) { return RDF_GetResource(NULL, "Local Files", 1); } else { memset(host, '\0', 100); s1 = charSearch(':', url)+3; s2 = charSearch('/', &url[s1]); s3 = charSearch(':', &url[s1]); if (s2 == -1) s2 = strlen(url)-s1; if ((s3 != -1) && (s2 > s3)) s2 = s3; if (startsWith("www", &url[s1])) {s1 = s1+4; s2 = s2-4;} if (s2<1) return(NULL); memcpy((char*)host, &url[s1], s2); host[0] = toupper(host[0]); hostResource = RDF_GetResource(NULL, host, 1); setContainerp(hostResource, 1); setResourceType(hostResource, HISTORY_RT); existing = PL_HashTableLookup(hostHash, hostResource); if (existing != NULL) { if (existing == nu) { return existing; } else if (existing == top) { return hostResource; } else { remoteStoreRemove(gRemoteStore, existing, gCoreVocab->RDF_parent, top, RDF_RESOURCE_TYPE); histAddParent(existing, hostResource); histAddParent(hostResource, top); PL_HashTableAdd(hostHash, hostResource, top); return hostResource; } } else { PL_HashTableAdd(hostHash, hostResource, nu); histAddParent(nu, top); return nu; } } }
/** remove the child from the directory **/ void ESRemoveChild (RDF_Resource parent, RDF_Resource child) { URL_Struct *urls; void *feData; if ((urls = NET_CreateURLStruct(resourceID(child), NET_SUPER_RELOAD)) != NULL) { feData = (void *)esMakeFEData(parent, child, URL_DELETE_METHOD); if (feData != NULL) { urls->method = URL_DELETE_METHOD; urls->fe_data = (void *)feData; NET_GetURL(urls, FO_PRESENT, (MWContext *)gRDFMWContext(), es_GetUrlExitFunc); } else { NET_FreeURLStruct(urls); } } }
PRBool isSeparator (RDF_Resource r) { return startsWith("separator", resourceID(r)); }
int ldapModifyEntry (RDFT rdf, RDF_Resource parent, RDF_Resource child, PRBool addFlag) { RDF_Cursor c; RDF_Resource newParent, r; char *urivals[2]; LDAP *ld; LDAPMod urimod, *mods[2]; LDAPURLDesc *ldURL=NULL; int err; char *errStr, *parentID; parentID = resourceID(parent); if (containerp(child)) { if (newParent = ldapNewContainer(parentID)) { if ((c = RDF_GetSources(rdf->rdf->rdf, child, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, 1)) != NULL) { while ((r = RDF_NextValue(c)) != NULL) { err = ldapModifyEntry(rdf, newParent, r, addFlag); if (err) { /* XXX MAJOR rollback issues! Punt for now! */ return(err); } } } else { return(-1); } } else { return(-1); } } ldap_url_parse(parentID, &ldURL); if (ldURL == NULL) return(-1); ld = ldap_init (ldURL->lud_host, ldURL->lud_port); if (ld == NULL) { ldap_free_urldesc(ldURL); return(-1); } if ((err = ldap_simple_bind_s(ld, ADMIN_ID, ADMIN_PW)) /* XXX */ != LDAP_SUCCESS) { if ((errStr = ldap_err2string(err)) != NULL) { XP_MakeHTMLAlert(NULL, errStr); } ldap_unbind(ld); ldap_free_urldesc(ldURL); return(-1); } urivals[0] = resourceID(child); urivals[1] = NULL; urimod.mod_op = ((addFlag == true) ? LDAP_MOD_ADD : LDAP_MOD_DELETE); urimod.mod_type = "labeledURI"; urimod.mod_values = urivals; mods[0] = &urimod; mods[1] = NULL; err = ldap_modify_s(ld, ldURL->lud_dn, mods); if (err != LDAP_SUCCESS) { if ((errStr = ldap_err2string(err)) != NULL) { XP_MakeHTMLAlert(NULL, errStr); } } ldap_unbind(ld); ldap_free_urldesc(ldURL); return(err); }
PRBool ldapContainerp (RDF_Resource u) { return(ldap_is_ldap_url(resourceID(u))); /* XXX ??? */ }
void possiblyAccessldap(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) { /** try to get the values of u.s from the directory **/ LDAP *ld; LDAPMessage *result=NULL, *entry; LDAPURLDesc *ldURL=NULL; RDF_Resource node; char *attrs[2], **vals; int err, i; char *title = NULL; /* Note: a labeledURI is a url followed by an optional [space title-string] */ if (!stringEquals(resourceID(s), resourceID(gCoreVocab->RDF_parent)) || (!inversep) || (!ldap_is_ldap_url(resourceID(u)))) return; ldap_url_parse(resourceID(u), &ldURL); if (ldURL == NULL) return; ld = ldap_init (ldURL->lud_host, ldURL->lud_port); if (ld == NULL) { ldap_free_urldesc(ldURL); return; } if ((err = ldap_simple_bind_s(ld, NULL, NULL)) != LDAP_SUCCESS) { ldap_unbind(ld); ldap_free_urldesc(ldURL); return; } attrs[0] = "labeledURI"; attrs[1] = NULL; err = ldap_search_s(ld, ldURL->lud_dn, LDAP_SCOPE_BASE, ldURL->lud_filter, attrs, 0, &result); if (err == LDAP_SUCCESS) { for (entry=ldap_first_entry(ld, result); entry!=NULL; entry=ldap_next_entry(ld, entry)) { if ((vals = ldap_get_values(ld, entry, attrs[0])) != NULL) { for (i=0; vals[i] != NULL; i++) { /* vals[i] has a URL... add into RDF graph */ /* if (((title = strstr(vals[i], " ")) != NULL) && (*(title+1) != '\0')) { *(++title) = '\0'; } else { title = NULL; } */ if ((node = RDF_Create(vals[i], true)) != NULL) { setResourceType(node, LDAP_RT); if (ldapContainerp(node) == true) { setContainerp(node, 1); } ldapDBAdd(rdf, node, gCoreVocab->RDF_parent, u, RDF_RESOURCE_TYPE); if (title != NULL) { ldapDBAdd(rdf, node, gCoreVocab->RDF_name, title, RDF_STRING_TYPE); } } } ldap_value_free(vals); } } } if (result != NULL) { ldap_msgfree(result); } ldap_unbind(ld); ldap_free_urldesc(ldURL); }
void HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource top, int indent) { RDF_Cursor c = RDF_GetSources(rdf, u, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true); RDF_Resource next; char *date, *name, *url; int loop; if (c == NULL) return; if (u == top) { name = RDF_GetResourceName(rdf, u); ht_rjcprintf(fp, "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n", NULL); ht_rjcprintf(fp, "<!-- This is an automatically generated file.\n", NULL); ht_rjcprintf(fp, "It will be read and overwritten.\n", NULL); ht_rjcprintf(fp, "Do Not Edit! -->\n", NULL); ht_rjcprintf(fp, "<TITLE>%s</TITLE>\n", (name) ? name:""); ht_rjcprintf(fp, "<H1>%s</H1>\n<DL><p>\n", (name) ? name:""); } while (next = RDF_NextValue(c)) { url = resourceID(next); if (containerp(next) && (!startsWith("ftp:",url)) && (!startsWith("file:",url)) && (!startsWith("IMAP:", url)) && (!startsWith("nes:", url)) && (!startsWith("mail:", url)) && (!startsWith("cache:", url)) && (!startsWith("ldap:", url))) { for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL); date = numericDate(resourceID(next)); ht_rjcprintf(fp, "<DT><H3 ADD_DATE=\"%s\">", (date) ? date:""); if (date) freeMem(date); name = RDF_GetResourceName(rdf, next); ht_rjcprintf(fp, "%s</H3>\n", name); for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL); ht_rjcprintf(fp, "<DL><p>\n", NULL); HT_WriteOutAsBookmarks1(rdf, fp, next, top, indent+1); for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL); ht_rjcprintf(fp, "</DL><p>\n", NULL); } else if (isSeparator(next)) { for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL); ht_rjcprintf(fp, "<HR>\n", NULL); } else { char* bkAddDate = (char*)RDF_GetSlotValue(rdf, next, gNavCenter->RDF_bookmarkAddDate, RDF_STRING_TYPE, false, true); for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL); ht_rjcprintf(fp, "<DT><A HREF=\"%s\" ", resourceID(next)); date = numericDate(bkAddDate); ht_rjcprintf(fp, "ADD_DATE=\"%s\" ", (date) ? date: ""); if (date) freeMem(date); ht_rjcprintf(fp, "LAST_VISIT=\"%s\" ", resourceLastVisitDate(rdf, next)); ht_rjcprintf(fp, "LAST_MODIFIED=\"%s\">", resourceLastModifiedDate(rdf, next)); ht_rjcprintf(fp, "%s</A>\n", RDF_GetResourceName(rdf, next)); if (resourceDescription(rdf, next) != NULL) { ht_rjcprintf(fp, "<DD>%s\n", resourceDescription(rdf, next)); } } } RDF_DisposeCursor(c); if (u == top) { ht_rjcprintf(fp, "</DL>\n", NULL); } }