Example #1
0
		public RoomHtml(RoomStub roomStub, bool loggedIn)
		{
			RoomStub = roomStub;

			ClientID = RoomStub.parentClientID + "_Room_" + RoomStub.guid;
			LinkID = ClientID + "_Link";
			//ArrowID = ClientID + "_Arrow";
			PresenceID = ClientID + "_Presence";
			CrossID = ClientID + "_Cross";
			TotalID = ClientID + "_Total";
			StatsSeperatorID = ClientID + "_StatsSeperator";
			UnreadID = ClientID + "_Unread";
			LoggedIn = loggedIn;

		}
Example #2
0
		public void InitialiseFromStub(RoomStub roomStub, DOMElement roomList, StateStub[] controllerStateStore)
		{
			stub = roomStub;

			Guid = stub.guid;
			Name = stub.name;
			Url = stub.url;
			Pinable = stub.pinable;
			pinned = stub.pinned;
			starred = stub.starred;
			Starrable = stub.starrable;
			isStarredByDefault = stub.isStarredByDefault;
			ReadOnly = stub.readOnly;
			IsPhotoChatRoom = stub.isPhotoChatRoom;
			IsPrivateChatRoom = stub.isPrivateChatRoom;
			IsNewPhotoAlertsRoom = stub.isNewPhotoAlertsRoom;
			Presence = stub.presence;
			tokenDateTimeTicks = stub.tokenDateTimeTicks;
			token = stub.token;
			hasArchive = stub.hasArchive;


			state = new StateStub();
			state.Initialise(
				stub.guid, 
				stub.selected,
				stub.guest,
				stub.newMessages,
				stub.totalMessages,
				stub.latestItem,
				stub.latestItemSeen,
				stub.latestItemOld,
				stub.listOrder,
				stub.tokenDateTimeTicks,
				stub.token);

			addToStateStoreIfNotAlreadyThere(controllerStateStore, state);

			html = new RoomHtml(stub, LoggedIn);

			string outerClientID = roomStub.parentClientID + "_Room_" + Guid + "_Outer";
			DOMElement newNode = Document.CreateElement("span");
			newNode.ID = outerClientID;
			newNode.InnerHTML = html.ToHtml();
			roomList.AppendChild(newNode.FirstChild);

			InitialiseElements(outerClientID);

			genericInitialise();
		}
Example #3
0
		public void InitialiseFromElement(DOMElement e, StateStub[] controllerStateStore)
		{
			Guid = e.Attributes.GetNamedItem("roomGuid").Value;
			Name = e.Attributes.GetNamedItem("roomName").Value;
			Url = e.Attributes.GetNamedItem("roomUrl").Value;
			Pinable = bool.Parse(e.Attributes.GetNamedItem("roomPinable").Value);
			pinned = bool.Parse(e.Attributes.GetNamedItem("roomPinned").Value);
			starred = bool.Parse(e.Attributes.GetNamedItem("roomStarred").Value);
			Starrable = bool.Parse(e.Attributes.GetNamedItem("roomStarrable").Value);
			isStarredByDefault = bool.Parse(e.Attributes.GetNamedItem("roomIsStarredByDefault").Value);
			ReadOnly = bool.Parse(e.Attributes.GetNamedItem("roomReadOnly").Value);
			IsPhotoChatRoom = bool.Parse(e.Attributes.GetNamedItem("roomIsPhotoChatRoom").Value);
			IsPrivateChatRoom = bool.Parse(e.Attributes.GetNamedItem("roomIsPrivateChatRoom").Value);
			IsNewPhotoAlertsRoom = bool.Parse(e.Attributes.GetNamedItem("roomIsNewPhotoAlertsRoom").Value);
			Presence = (PresenceState)int.ParseInvariant(e.Attributes.GetNamedItem("roomPresence").Value);

			Icon = e.Attributes.GetNamedItem("roomIcon").Value;
			tokenDateTimeTicks = e.Attributes.GetNamedItem("roomTokenDateTimeTicks").Value;
			token = e.Attributes.GetNamedItem("roomToken").Value;
			hasArchive = bool.Parse(e.Attributes.GetNamedItem("roomHasArchive").Value);

			hiddenFromRoomList = bool.Parse(e.Attributes.GetNamedItem("roomHiddenFromRoomList").Value);
			isStreamRoom = bool.Parse(e.Attributes.GetNamedItem("roomisStreamRoom").Value);

			state = new StateStub();
			state.Initialise(
				Guid,
				bool.Parse(e.Attributes.GetNamedItem("roomSelected").Value),
				bool.Parse(e.Attributes.GetNamedItem("roomGuest").Value), 
				int.ParseInvariant(e.Attributes.GetNamedItem("roomNewMessages").Value), 
				int.ParseInvariant(e.Attributes.GetNamedItem("roomTotalMessages").Value), 
				e.Attributes.GetNamedItem("roomLatestItem").Value, 
				e.Attributes.GetNamedItem("roomLatestItemSeen").Value,
				e.Attributes.GetNamedItem("roomLatestItemOld").Value,
				int.ParseInvariant(e.Attributes.GetNamedItem("roomListOrder").Value),
				tokenDateTimeTicks,
				token);

			addToStateStoreIfNotAlreadyThere(controllerStateStore, state);

			stub = new RoomStub(
				Parent.ClientID, 
				Guid, 
				Name, 
				Url,
				Pinned,
				Starred,
				isStarredByDefault,
				Pinable,
				Starrable,
				Selected,
				Guest, 
				NewMessages, 
				TotalMessages, 
				LatestItem, 
				LatestItemSeen, 
				LatestItemOld,
				ReadOnly,
				state.listOrder,
				IsPhotoChatRoom,
				IsPrivateChatRoom,
				IsNewPhotoAlertsRoom,
				Presence,
				Icon,
				tokenDateTimeTicks,
				token,
				hasArchive,
				hiddenFromRoomList,
				isStreamRoom);
			
			html = new RoomHtml(stub, LoggedIn);

			InitialiseElements("");

			genericInitialise();
		}
Example #4
0
		public PinStub SwitchPhotoRoom(string clientID, string roomGuid, string lastItemGuidString, int sessionID, string lastActionTicks, string pageUrl, StateStub[] roomState)
		{
			WaitIfDevEnv();

			Guid guid = roomGuid.UnPackGuid();
			Chat.RoomSpec spec = Chat.RoomSpec.FromGuid(guid);
			int usrK = Usr.Current == null ? 0 : Usr.Current.K;

			if (spec == null)
				throw new InvalidRoomException();

			if (!spec.CheckPermission(Usr.Current, false))
				throw new ReadPermissionException();

			storeRoomState(roomState, usrK);

			RoomStub r;

			string tokenDateTime = DateTime.Now.Ticks.ToString();
			string token = Chat.GetToken(guid, tokenDateTime);

			//we should add the new guest room to the state stubs...
			StateStub ss = new StateStub();
			ss.guid = roomGuid;
			ss.guest = true;
			ss.listOrder = -1;
			ss.tokenDateTimeTicks = tokenDateTime;
			ss.token = token;
			List<StateStub> roomStateList = roomState.ToList();
			roomStateList.Add(ss);
			roomState = roomStateList.ToArray();

			lastActionTicks = resetLastActionAndSessionID(sessionID);

			r = new RoomStub(
				clientID,
				guid.Pack(),
				spec.GetName(Usr.Current),
				spec.GetUrl(Usr.Current),
				false,
				spec.IsStarredByDefault,
				spec.IsStarredByDefault,
				true,
				spec.IsStarrable,
				false,
				true,
				0,
				0,
				"",
				"",
				"",
				spec.IsReadOnly,
				-1,
				spec.IsPhotoChatRoom,
				spec.IsPrivateChatRoom,
				spec.IsNewPhotoAlertsRoom,
				spec.GetPrivateChatRoomPresence(Usr.Current),
				spec.Icon,
				tokenDateTime,
				token,
				spec.HasArchive,
				spec.HiddenFromRoomList,
				spec.IsStreamRoom);

			Guid lastItemGuidReturned = Guid.Empty;
			Guid lastItemGuid = lastItemGuidString.Length == 0 ? Guid.Empty : lastItemGuidString.UnPackGuid();

			ChatLibrary.ChatServerInterface cs = (ChatLibrary.ChatServerInterface)Activator.GetObject(typeof(ChatLibrary.ChatServerInterface), Bobs.Vars.ChatServerAddress);
			string chatItems = cs.GetLatest(usrK, sessionID, false, lastItemGuid, ref lastItemGuidReturned);

			PinStub ps = new PinStub();
			ps.roomStub = r;
			ps.itemsJson = chatItems;
			ps.lastActionTicks = lastActionTicks;
			ps.lastItemGuidReturned = lastItemGuidReturned.Pack();
			return ps;
		}
Example #5
0
		public PinStub Pin(string clientID, string roomGuid, string lastItemGuidString, int sessionID, string lastActionTicks, string pageUrl, StateStub[] roomState)
		{
			WaitIfDevEnv();

			Guid guid = roomGuid.UnPackGuid();
			Chat.RoomSpec spec = Chat.RoomSpec.FromGuid(guid);

			if (Usr.Current == null || Usr.Current.IsSkeleton || Usr.Current.Banned)
				throw new LoginPermissionException();

			if (spec == null)
				throw new InvalidRoomException();

			if (!spec.CheckPermission(Usr.Current, false))
				throw new ReadPermissionException();

			storeRoomState(roomState, Usr.Current.K);

			RoomStub r;

			if (spec.RoomType == RoomType.BuddyAlerts && spec.ObjectK > 0)
			{
				if (spec.ObjectK == Usr.Current.K)
					throw new SelfPrivateChatRoomException();

				spec = new Chat.RoomSpec(spec.ObjectK, Usr.Current.K);
				guid = spec.Guid;
			}

			if (spec.RoomType == RoomType.PrivateChat && spec.ObjectK > 0 && spec.SecondObjectK == 0)
			{
				if (spec.ObjectK == Usr.Current.K)
					throw new SelfPrivateChatRoomException();

				spec = new Chat.RoomSpec(spec.ObjectK, Usr.Current.K);
				guid = spec.Guid;
			}

			if (!spec.CheckPermission(Usr.Current, false))
				throw new ReadPermissionException();


			lastActionTicks = resetLastActionAndSessionID(sessionID);
			RoomPin p = getOrCreateRoomPin(guid, null, Usr.Current.K);

			r = new RoomStub(
				clientID, 
				guid.Pack(), 
				spec.GetName(Usr.Current), 
				spec.GetUrl(Usr.Current),
				true,
				spec.IsStarredByDefault,
				spec.IsStarredByDefault,
				true,
				spec.IsStarrable,
				false, 
				false, 
				0, 
				0, 
				"", 
				"", 
				"", 
				spec.IsReadOnly, 
				p.ListOrder, 
				spec.IsPhotoChatRoom,
				spec.IsPrivateChatRoom,
				spec.IsNewPhotoAlertsRoom,
				spec.GetPrivateChatRoomPresence(Usr.Current),
				spec.Icon,
				"",
				"",
				spec.HasArchive,
				spec.HiddenFromRoomList,
				spec.IsStreamRoom);

			Guid lastItemGuidReturned = Guid.Empty;
			Guid lastItemGuid = lastItemGuidString.Length == 0 ? Guid.Empty : lastItemGuidString.UnPackGuid();

			ChatLibrary.ChatServerInterface cs = (ChatLibrary.ChatServerInterface)Activator.GetObject(typeof(ChatLibrary.ChatServerInterface), Bobs.Vars.ChatServerAddress);
			string chatItems = cs.PinRoom(Usr.Current.K, sessionID, lastItemGuid, ref lastItemGuidReturned, guid);

			PinStub ps = new PinStub();
			ps.roomStub = r;
			ps.itemsJson = chatItems;
			ps.lastActionTicks = lastActionTicks;
			ps.lastItemGuidReturned = lastItemGuidReturned.Pack();
			return ps;
		}
Example #6
0
		void updateUI(RoomStub selectedRoom, List<Guid> roomsOrder, bool hasGuestRooms, bool hasPrivateRooms)
		{
			bool readOnly = true;
			bool isPrivateRoom = false;
			if (selectedRoom != null)
			{
				Chat.RoomSpec selectedRoomSpec = Chat.RoomSpec.FromGuid(selectedRoom.guid.UnPackGuid());
				readOnly = selectedRoomSpec.IsReadOnly;
				isPrivateRoom = selectedRoomSpec.IsPrivateChatRoom;
			}
			RoomGuestListDivider.Style["display"] = hasGuestRooms ? "" : "none";
			RoomGuestList.Style["display"] = hasGuestRooms ? "" : "none";
			//RoomPrivateListDivider.Style["display"] = hasPrivateRooms ? "" : "none";
			RoomPrivateList.Style["display"] = hasPrivateRooms ? "" : "none";
			TextBox.Style["display"] = readOnly ? "none" : "";
			DeleteArchiveHolder.Style["display"] = isPrivateRoom ? "" : "none";
		}
Example #7
0
		public GotRoomEventArgs(RoomStub roomStub)
		{
			RoomStub = roomStub;
		}