public void SetMucRoomSettings(Jid roomName, MucRoomSettings settings) { if (Jid.IsNullOrEmpty(roomName)) { throw new ArgumentNullException("roomName"); } if (settings == null) { throw new ArgumentNullException("settings"); } ExecuteNonQuery( new SqlInsert("jabber_room", true) .InColumnValue("jid", roomName.Bare) .InColumnValue("title", settings.Title ?? roomName.User) .InColumnValue("subject", settings.Subject) .InColumnValue("instructions", settings.Instructions) .InColumnValue("pwd", settings.Password) .InColumnValue("pwdprotect", settings.PasswordProtected) .InColumnValue("visible", settings.Visible) .InColumnValue("members", settings.GetMemberList()) .InColumnValue("maxoccupant", settings.MaxOccupant) .InColumnValue("historycountonenter", settings.HistoryCountOnEnter) .InColumnValue("anonymous", settings.Anonymous) .InColumnValue("logging", settings.Logging) .InColumnValue("membersonly", settings.MembersOnly) .InColumnValue("usernamesonly", settings.UserNamesOnly) .InColumnValue("moderated", settings.Moderated) .InColumnValue("persistent", settings.Persistent) .InColumnValue("presencebroadcastedfrom", settings.PresenceBroadcastedFrom) .InColumnValue("canchangesubject", settings.CanChangeSubject) .InColumnValue("caninvite", settings.CanInvite) .InColumnValue("canseememberlist", settings.CanSeeMemberList)); }
public void MucRoomSettingsTest() { var room1 = new Jid("a.conf@s/R"); store.RemoveMuc(room1); var s = store.GetMucRoomSettings(room1); Assert.IsNull(s); s = new MucRoomSettings(); store.SetMucRoomSettings(room1, s); s = store.GetMucRoomSettings(room1); Assert.IsNotNull(s); s.Members = new List <MucRoomMemberInfo>(); var m1 = new MucRoomMemberInfo("1:1:1"); var m2 = new MucRoomMemberInfo("2:1:1"); s.Members.Add(m1); s.Members.Add(m2); store.SetMucRoomSettings(room1, s); s = store.GetMucRoomSettings(room1); Assert.AreEqual(2, s.Members.Count); store.RemoveMuc(room1); s = store.GetMucRoomSettings(room1); Assert.IsNull(s); }
public void SaveMuc(MucRoomInfo muc) { if (muc == null) { throw new ArgumentNullException("muc"); } SetMucRoomSettings(muc.Jid, MucRoomSettings.CreateDefault(null)); }
public MucRoomSettings GetMucRoomSettings(Jid roomName) { if (Jid.IsNullOrEmpty(roomName)) { throw new ArgumentNullException("roomName"); } return(ExecuteList(new SqlQuery("jabber_room").Where("jid", roomName.Bare) .Select("anonymous") .Select("canchangesubject") .Select("caninvite") .Select("canseememberlist") .Select("historycountonenter") .Select("instructions") .Select("logging") .Select("maxoccupant") .Select("membersonly") .Select("moderated") .Select("pwd") .Select("pwdprotect") .Select("persistent") .Select("presencebroadcastedfrom") .Select("subject") .Select("title") .Select("usernamesonly") .Select("visible") .Select("members")) .ConvertAll(o => new MucRoomSettings { Anonymous = Convert.ToBoolean(o[0]), CanChangeSubject = Convert.ToBoolean(o[1]), CanInvite = Convert.ToBoolean(o[2]), CanSeeMemberList = (Role)Convert.ToInt32(o[3]), HistoryCountOnEnter = Convert.ToInt32(o[4]), Instructions = o[5] as string, Logging = Convert.ToBoolean(o[6]), MaxOccupant = Convert.ToInt32(o[7]), MembersOnly = Convert.ToBoolean(o[8]), Moderated = Convert.ToBoolean(o[9]), Password = o[10] as string, PasswordProtected = Convert.ToBoolean(o[11]), Persistent = Convert.ToBoolean(o[12]), PresenceBroadcastedFrom = (Role)Convert.ToInt32(o[13]), Subject = o[14] as string, Title = o[15] as string, UserNamesOnly = Convert.ToBoolean(o[16]), Visible = Convert.ToBoolean(o[17]), Members = MucRoomSettings.ParseMemberList(o[18] as string) }) .SingleOrDefault()); }
private void LoadRoomSettings() { RoomSettings = mucService.MucStorage.GetMucRoomSettings(Jid); if (RoomSettings == null) { RoomSettings = MucRoomSettings.CreateDefault(this); mucService.MucStorage.SetMucRoomSettings(Jid, RoomSettings); } else { RoomSettings.Room = this; } UpdateDiscoInfo(); visible = RoomSettings.Visible; }