// OntologyGadgets public PreparedGadget(GadgetSpec gadgetSpec, OpenSocialManager openSocialManager, string view, string optParams) { this.gadgetSpec = gadgetSpec; this.openSocialManager = openSocialManager; this.securityToken = openSocialManager.GetSecurityToken(gadgetSpec.GetGadgetURL()); this.view = view; this.chromeId = "gadgets-ontology-" + GetAppId(); this.optParams = optParams == null || optParams.Trim() == string.Empty ? "{}" : optParams; }
private List <PreparedGadget> GetSandboxGadgets(Dictionary <string, GadgetSpec> allDBGadgets, string requestAppId) { List <PreparedGadget> sandboxGadgets = new List <PreparedGadget>(); // Add sandbox gadgets if there are any // Note that this block of code only gets executed after someone logs in with GadgetSandbox.aspx! String openSocialGadgetURLS = (string)page.Session[OPENSOCIAL_GADGETS]; String[] urls = openSocialGadgetURLS.Split(Environment.NewLine.ToCharArray()); for (int i = 0; i < urls.Length; i++) { String openSocialGadgetURL = urls[i]; if (openSocialGadgetURL.Length == 0) { continue; } int appId = 0; // if URL matches one in the DB, use DB provided appId, otherwise generate one string gadgetFileName = GetGadgetFileNameFromURL(openSocialGadgetURL); string name = gadgetFileName; string[] channels = new string[0]; bool sandboxOnly = true; // see if we have a gadget with the same file name in the DB, if so use its configuration if (allDBGadgets.ContainsKey(gadgetFileName)) { appId = allDBGadgets[gadgetFileName].GetAppId(); name = allDBGadgets[gadgetFileName].GetName(); sandboxOnly = false; } else { CharEnumerator ce = openSocialGadgetURL.GetEnumerator(); while (ce.MoveNext()) { appId += (int)ce.Current; } } // if they asked for a specific one, only let it in if (requestAppId != null && Convert.ToInt32(requestAppId) != appId) { continue; } GadgetSpec gadgetSpec = new GadgetSpec(appId, name, openSocialGadgetURL, true, sandboxOnly); // only add ones that are visible in this context! int moduleId = 0; if (sandboxOnly || gadgetSpec.Show(viewerUri, ownerUri, page.AppRelativeVirtualPath.Substring(2).ToLower())) { String securityToken = SocketSendReceive(viewerUri, ownerUri, gadgetSpec.GetGadgetURL()); sandboxGadgets.Add(new PreparedGadget(gadgetSpec, this, moduleId++, securityToken)); } } return(sandboxGadgets); }
// tool gadgets public PreparedGadget(GadgetSpec gadgetSpec, OpenSocialManager openSocialManager) { this.gadgetSpec = gadgetSpec; this.openSocialManager = openSocialManager; this.securityToken = openSocialManager.GetSecurityToken(gadgetSpec.GetGadgetURL()); // look at the view requirements and what page we are on to set some things GadgetViewRequirements viewReqs = GetGadgetViewRequirements(); if (viewReqs != null) { this.view = viewReqs.GetView(); this.chromeId = viewReqs.GetChromeIdBase() + "-" + GetAppId(); this.optParams = viewReqs.GetOptParams(); } else // must be a sandbox gadget { this.view = "sandbox"; this.chromeId = "gadgets-sandbox-" + GetAppId(); this.optParams = "{}"; } }
// OntologyGadgets public PreparedGadget(GadgetSpec gadgetSpec, OpenSocialManager openSocialManager, string view, string optParams, string chromeId) { this.gadgetSpec = gadgetSpec; this.openSocialManager = openSocialManager; this.securityToken = SocketSendReceive(openSocialManager.GetViewerURI(), openSocialManager.GetOwnerURI(), gadgetSpec.GetGadgetURL()); this.view = view; this.chromeId = chromeId; this.optParams = optParams == null || optParams.Trim() == string.Empty ? "{}" : optParams; }
// tool gadgets public PreparedGadget(GadgetSpec gadgetSpec, OpenSocialManager openSocialManager) { this.gadgetSpec = gadgetSpec; this.openSocialManager = openSocialManager; this.securityToken = SocketSendReceive(openSocialManager.GetViewerURI(), openSocialManager.GetOwnerURI(), gadgetSpec.GetGadgetURL()); // look at the view requirements and what page we are on to set some things GadgetViewRequirements viewReqs = GetGadgetViewRequirements(); if (viewReqs != null) { this.view = viewReqs.GetView(); this.chromeId = viewReqs.GetChromeId(); this.optParams = viewReqs.GetOptParams(); } else // must be a sandbox gadget { this.view = ""; this.chromeId = "gadgets-test-" + gadgetSpec.GetAppId(); this.optParams = "{}"; } }
public string GetGadgetURL() { return(gadgetSpec.GetGadgetURL()); }
private List<PreparedGadget> GetSandboxGadgets(Dictionary<string, GadgetSpec> allDBGadgets, string requestAppId) { List<PreparedGadget> sandboxGadgets = new List<PreparedGadget>(); // Add sandbox gadgets if there are any // Note that this block of code only gets executed after someone logs in with GadgetSandbox.aspx! String openSocialGadgetURLS = (string)page.Session[OPENSOCIAL_GADGETS]; String[] urls = openSocialGadgetURLS.Split(Environment.NewLine.ToCharArray()); for (int i = 0; i < urls.Length; i++) { String openSocialGadgetURL = urls[i]; if (openSocialGadgetURL.Length == 0) continue; int appId = 0; // if URL matches one in the DB, use DB provided appId, otherwise generate one string gadgetFileName = GetGadgetFileNameFromURL(openSocialGadgetURL); string name = gadgetFileName; string[] channels = new string[0]; bool sandboxOnly = true; // see if we have a gadget with the same file name in the DB, if so use its configuration if (allDBGadgets.ContainsKey(gadgetFileName)) { appId = allDBGadgets[gadgetFileName].GetAppId(); name = allDBGadgets[gadgetFileName].GetName(); channels = allDBGadgets[gadgetFileName].GetChannels(); sandboxOnly = false; } else { CharEnumerator ce = openSocialGadgetURL.GetEnumerator(); while (ce.MoveNext()) { appId += (int)ce.Current; } } // if they asked for a specific one, only let it in if (requestAppId != null && Convert.ToInt32(requestAppId) != appId) { continue; } GadgetSpec gadgetSpec = new GadgetSpec(appId, name, openSocialGadgetURL, channels, true, sandboxOnly); // only add ones that are visible in this context! int moduleId = 0; if (sandboxOnly || gadgetSpec.Show(viewerId, ownerId, page.AppRelativeVirtualPath.Substring(2).ToLower())) { String securityToken = SocketSendReceive(viewerId, ownerId, gadgetSpec.GetGadgetURL()); sandboxGadgets.Add(new PreparedGadget(gadgetSpec, this, moduleId++, securityToken)); } } return sandboxGadgets; }