/// <summary> /// Shares a calendar with the specified user. Note that this method /// will not run by default. /// </summary> /// <param name="service">The authenticated CalendarService object.</param> /// <param name="aclFeedUri">the ACL feed URI of the calendar being shared.</param> /// <param name="userEmail">The email address of the user with whom to share.</param> /// <param name="role">The role of the user with whom to share.</param> /// <returns>The AclEntry returned by the server.</returns> static AclEntry AddAccessControl(CalendarService service, string aclFeedUri, string userEmail, AclRole role) { AclEntry entry = new AclEntry(); entry.Scope = new AclScope(); entry.Scope.Type = AclScope.SCOPE_USER; entry.Scope.Value = userEmail; entry.Role = role; Uri aclUri = new Uri("http://www.google.com/calendar/feeds/[email protected]/acl/full"); AclEntry insertedEntry = service.Insert(aclUri, entry); Console.WriteLine("Added user {0}", insertedEntry.Scope.Value); return insertedEntry; }
/// <summary> /// Updates a user to have new access permissions over a calendar. /// Note that this method will not run by default. /// </summary> /// <param name="entry">An existing AclEntry representing sharing permissions.</param> /// <param name="newRole">The new role (access permissions) for the user.</param> /// <returns>The updated AclEntry.</returns> static AclEntry UpdateEntry(AclEntry entry, AclRole newRole) { entry.Role = newRole; AclEntry updatedEntry = entry.Update() as AclEntry; Console.WriteLine("Updated {0} to have role {1}", updatedEntry.Scope.Value, entry.Role.Value); return updatedEntry; }
/// <summary> /// parse method is called from the atom parser to populate an Transparency node /// </summary> /// <param name="node">the xmlnode to parser</param> /// <returns>Notifications object</returns> public static AclRole parse(XmlNode node) { AclRole role = null; Tracing.TraceMsg("Parsing a gAcl:AclRole"); if (String.Compare(node.NamespaceURI, AclNameTable.gAclNamespace, true) == 0 && String.Compare(node.LocalName, AclNameTable.XmlAclRoleElement) == 0) { role = new AclRole(); if (node.Attributes != null) { role.Value = node.Attributes["value"].Value; Tracing.TraceMsg("AclRole parsed, value = " + role.Value); } } return role; }