示例#1
0
        public void RepoEnsureICanAddANewBiopsy()
        {
            ProviderUser user = new ProviderUser {
                ProviderUserId = 500
            };

            List <Biopsy> emptyDB = new List <Biopsy>(); //This is the empty database

            ConnectMocksToDataStore(emptyDB);

            int          BiopsyID           = 1;
            ProviderUser provider           = user;
            string       BioType            = "Ultrasound";
            string       BioDate            = "2/4/2015";
            string       PathClassification = "Malignant";
            string       PathType           = "IMC";
            string       PatLastName        = "Jones";
            string       PatDOB             = "12/5/1965";
            string       ProvLastName       = "Han";
            string       TechnologistName   = "Suzy";

            //Listen for any item trying to be added to the database. When you see one add it to emptyDB
            mock_set.Setup(i => i.Add(It.IsAny <Biopsy>())).Callback((Biopsy s) => emptyDB.Add(s));

            bool added = repo.AddNewBiopsy(user, BiopsyID, BioType, BioDate, PathClassification, PathType, PatLastName, PatDOB, ProvLastName, TechnologistName);

            Assert.IsTrue(added);
            Assert.AreEqual(1, repo.GetAllBiopsies().Count);
        }
示例#2
0
        public async Task CreateAsync(string ownerEmail)
        {
            var owner = await _userRepository.GetByEmailAsync(ownerEmail);

            if (owner == null)
            {
                throw new BadRequestException("Invalid owner. Owner must be an existing Bitwarden user.");
            }

            var provider = new Provider
            {
                Status    = ProviderStatusType.Pending,
                Enabled   = true,
                UseEvents = true,
            };
            await _providerRepository.CreateAsync(provider);

            var providerUser = new ProviderUser
            {
                ProviderId = provider.Id,
                UserId     = owner.Id,
                Type       = ProviderUserType.ProviderAdmin,
                Status     = ProviderUserStatusType.Confirmed,
            };
            await _providerUserRepository.CreateAsync(providerUser);

            await SendProviderSetupInviteEmailAsync(provider, owner.Email);
        }
        public async Task CompleteSetupAsync(Provider provider, Guid ownerUserId, string token, string key)
        {
            var owner = await _userService.GetUserByIdAsync(ownerUserId);

            if (owner == null)
            {
                throw new BadRequestException("Invalid owner.");
            }

            if (!CoreHelpers.TokenIsValid("ProviderSetupInvite", _dataProtector, token, owner.Email, provider.Id, _globalSettings))
            {
                throw new BadRequestException("Invalid token.");
            }

            await _providerRepository.UpsertAsync(provider);

            var providerUser = new ProviderUser
            {
                ProviderId = provider.Id,
                UserId     = owner.Id,
                Key        = key,
                Status     = ProviderUserStatusType.Confirmed,
                Type       = ProviderUserType.ProviderAdmin,
            };

            await _providerUserRepository.CreateAsync(providerUser);
        }
        public void ShouldUpdateUserProviderWhenEmailVerificationCodeIsValid()
        {
            // Arrange.
            const string username = "******";
            const string emailVerificationCode = "ABC123";

            var providerUser = new ProviderUser
            {
                Status = ProviderUserStatus.Registered,
                EmailVerificationCode = emailVerificationCode,
                EmailVerifiedDate     = null
            };

            _mockUserProfileService
            .Setup(mock => mock.GetProviderUser(username))
            .Returns(providerUser);

            var providerUserProvider = new ProviderUserProviderBuilder()
                                       .With(_mockUserProfileService)
                                       .Build();

            // Act.
            var result = providerUserProvider.ValidateEmailVerificationCode(username, emailVerificationCode);

            // Assert.
            result.Should().BeTrue();

            _mockUserProfileService.Verify(mock =>
                                           mock.UpdateProviderUser(providerUser), Times.Once);

            providerUser.Status.Should().Be(ProviderUserStatus.EmailVerified);
            providerUser.EmailVerificationCode.Should().BeNull();
            providerUser.EmailVerifiedDate.Should().BeCloseTo(DateTime.UtcNow, 1000);
        }
        public async Task CreateAsync(string ownerEmail)
        {
            var owner = await _userRepository.GetByEmailAsync(ownerEmail);

            if (owner == null)
            {
                throw new BadRequestException("Invalid owner.");
            }

            var provider = new Provider
            {
                Status  = ProviderStatusType.Pending,
                Enabled = true,
            };
            await _providerRepository.CreateAsync(provider);

            var providerUser = new ProviderUser
            {
                ProviderId = provider.Id,
                UserId     = owner.Id,
                Type       = ProviderUserType.ProviderAdmin,
                Status     = ProviderUserStatusType.Confirmed,
            };
            await _providerUserRepository.CreateAsync(providerUser);

            var token = _dataProtector.Protect($"ProviderSetupInvite {provider.Id} {owner.Email} {CoreHelpers.ToEpocMilliseconds(DateTime.UtcNow)}");
            await _mailService.SendProviderSetupInviteEmailAsync(provider, token, owner.Email);
        }
        private ProviderUserViewModel Convert(ProviderUser providerUser)
        {
            ReleaseNoteViewModel releaseNoteViewModel = null;
            var releaseNotes = _referenceDataService.GetReleaseNotes(DasApplication.Recruit);
            var releaseNote  = releaseNotes?.LastOrDefault(rn => rn.Version > providerUser.ReleaseNoteVersion);

            if (releaseNote != null)
            {
                releaseNoteViewModel = new ReleaseNoteViewModel
                {
                    Version = releaseNote.Version,
                    Note    = releaseNote.Note
                };
            }

            var viewModel = new ProviderUserViewModel
            {
                ProviderUserId        = providerUser.ProviderUserId,
                ProviderUserGuid      = providerUser.ProviderUserGuid,
                ProviderId            = providerUser.ProviderId,
                Ukprn                 = providerUser.Ukprn,
                ProviderName          = providerUser.ProviderName,
                Username              = providerUser.Username,
                DefaultProviderSiteId = providerUser.PreferredProviderSiteId ?? 0,
                EmailAddress          = providerUser.Email,
                EmailAddressVerified  = providerUser.Status == ProviderUserStatus.EmailVerified,
                Fullname              = providerUser.Fullname,
                PhoneNumber           = providerUser.PhoneNumber,
                CreatedDateTime       = providerUser.CreatedDateTime,
                ReleaseNoteViewModel  = releaseNoteViewModel
            };

            return(viewModel);
        }
示例#7
0
        private Email MapToEmail(ProviderUser user, IList <ProviderAlertSummary> alertSummaries)
        {
            var alert = alertSummaries.Single(m => m.ProviderId == user.Ukprn);

            return(new Email
            {
                RecipientsAddress = user.Email,
                TemplateId = "ProviderAlertSummaryNotification",
                ReplyToAddress = "*****@*****.**",
                Subject = "Items for your attention: apprenticeship service",
                SystemId = "x",
                Tokens =
                    new Dictionary <string, string>
                {
                    { "name", user.GivenName },
                    { "total_count_text", alert.TotalCount == 1
                                ? "is 1 apprentice"
                                : $"are {alert.TotalCount} apprentices" },
                    { "provider_name", alert.ProviderName },
                    { "need_needs", alert.TotalCount > 1 ? "need" :"needs" },
                    { "changes_for_review", ChangesForReviewText(alert.ChangesForReview) },
                    { "mismatch_changes", GetMismatchText(alert.DataMismatchCount) },
                    { "link_to_mange_apprenticeships", $"{user.Ukprn}/apprentices/manage/all?RecordStatus=ChangesForReview&RecordStatus=IlrDataMismatch&RecordStatus=ChangeRequested" }
                }
            });
        }
        public void ShouldValidateEmailVerificationCodeCaseInsensitive(
            string savedEmailVerificationCode, string enteredEmailVerificationCode)
        {
            // Arrange.
            const string username = "******";

            var providerUser = new ProviderUser
            {
                EmailVerificationCode = savedEmailVerificationCode
            };

            _mockUserProfileService
            .Setup(mock => mock.GetProviderUser(username))
            .Returns(providerUser);

            var providerUserProvider = new ProviderUserProviderBuilder()
                                       .With(_mockUserProfileService)
                                       .Build();

            // Act.
            var result = providerUserProvider.ValidateEmailVerificationCode(username, enteredEmailVerificationCode);

            // Assert.
            result.Should().BeTrue();
        }
 public ProviderDataDto(ProviderUser user)
 {
     Email = user.Email;
     Location = user.Location;
     CompanyName = user.CompanyName;
     Description = user.Description;
     URL = user.URL;
 }
示例#10
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProviderUser providerUser = db.ProviderUser.Find(id);

            db.ProviderUser.Remove(providerUser);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ProviderDataDto(ProviderUser user)
 {
     Email       = user.Email;
     Location    = user.Location;
     CompanyName = user.CompanyName;
     Description = user.Description;
     URL         = user.URL;
 }
示例#12
0
 public void ProviderUserAdded(ProviderUser user)
 {
     Person person = PersonManager.GetPerson(user);
     if(person == null) {
         person = new Person(user);
         //person.JabberId = user.Uri;
         PersonManager.AddPerson(person);
     }
 }
        public void ProviderUserEnsureProviderUserHasAllThings()
        {
            ProviderUser a_user = new ProviderUser();

            a_user.ProviderUserId = 1;
            a_user.Email          = "*****@*****.**";

            Assert.AreEqual(1, a_user.ProviderUserId);
            Assert.AreEqual("*****@*****.**", a_user.Email);
        }
示例#14
0
 public ActionResult Edit([Bind(Include = "ProviderUserId,Email")] ProviderUser providerUser)
 {
     if (ModelState.IsValid)
     {
         db.Entry(providerUser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(providerUser));
 }
        public async Task <List <ProviderUser> > InviteUserAsync(Guid providerId, Guid invitingUserId,
                                                                 ProviderUserInvite invite)
        {
            var provider = await _providerRepository.GetByIdAsync(providerId);

            if (provider == null || invite?.Emails == null || !invite.Emails.Any())
            {
                throw new NotFoundException();
            }

            var providerUsers = new List <ProviderUser>();

            foreach (var email in invite.Emails)
            {
                // Make sure user is not already invited
                var existingProviderUserCount =
                    await _providerUserRepository.GetCountByProviderAsync(providerId, email, false);

                if (existingProviderUserCount > 0)
                {
                    continue;
                }

                var providerUser = new ProviderUser
                {
                    ProviderId   = providerId,
                    UserId       = null,
                    Email        = email.ToLowerInvariant(),
                    Key          = null,
                    Type         = invite.Type,
                    Status       = ProviderUserStatusType.Invited,
                    CreationDate = DateTime.UtcNow,
                    RevisionDate = DateTime.UtcNow,
                };

                if (invite.Permissions != null)
                {
                    providerUser.Permissions = JsonSerializer.Serialize(invite.Permissions, new JsonSerializerOptions
                    {
                        PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    });
                }

                await _providerUserRepository.CreateAsync(providerUser);

                await SendInviteAsync(providerUser, provider);

                providerUsers.Add(providerUser);
            }

            await _eventService.LogProviderUsersEventAsync(providerUsers.Select(pu => (pu, EventType.ProviderUser_Invited, null as DateTime?)));

            return(providerUsers);
        }
示例#16
0
        public ActionResult Create([Bind(Include = "ProviderUserId,Email")] ProviderUser providerUser)
        {
            if (ModelState.IsValid)
            {
                db.ProviderUser.Add(providerUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(providerUser));
        }
        public IHttpActionResult GetProviderUser(int id)
        {
            ProviderUser providerUser = db.Users.FirstOrDefault(u => u.Id == id) as ProviderUser;

            if (providerUser == null)
            {
                return(NotFound());
            }

            return(Ok(new ProviderDataDto(providerUser)));
        }
示例#18
0
        public UserViewModel(UserModel userModel, ProviderUser providerUser)
        {
            this.userModel    = userModel;
            this.providerUser = providerUser;
            newPayment        = new PaymentModel();

            AddCommandModel        = new AddCommand(this);
            BlockedCommandModel    = new BlockedCommand(this);
            UnBlockedCommandModel  = new UnBlockedCommand(this);
            ViewJornalCommandModel = new ViewJornalCommand(this);
            PayCommandModel        = new PayCommand(this);
        }
 // TODO: AG: move to UpdateEntityTimestamps to one place.
 private static void UpdateEntityTimestamps(ProviderUser entity)
 {
     if (entity.CreatedDateTime == DateTime.MinValue)
     {
         entity.CreatedDateTime = DateTime.UtcNow;
         entity.UpdatedDateTime = null;
     }
     else
     {
         entity.UpdatedDateTime = DateTime.UtcNow;
     }
 }
示例#20
0
        private async Task <AuthorizationToken> CreateTokenAsync(ProviderUser providerUser)
        {
            Account domainUser = _accountsRepository.FindBy(a => a.ProviderId == providerUser.ProviderId).FirstOrDefault();

            if (domainUser == null)
            {
                domainUser = await _accountsRepository.AddAsync(domainUser);

                await _unitOfWork.SaveChangesAsync();
            }

            return(_tokenService.CreateToken(domainUser));
        }
示例#21
0
        // GET: StaticProvider
        public ActionResult Index()
        {
            ProviderUser providerUser = db.Users.OfType <ProviderUser>().FirstOrDefault(u => u.Email == User.Identity.Name);

            if (providerUser != null)
            {
                List <GeneralUser> otherTypeOfUsers = providerUser is StudentUser?db.Users.OfType <ProviderUser>().Cast <GeneralUser>().ToList() : db.Users.OfType <StudentUser>().Cast <GeneralUser>().ToList();

                ViewBag.Recommendations = new ProviderMatcher(providerUser).GetMatchingProvider(otherTypeOfUsers);
            }

            return(View(providerUser));
        }
示例#22
0
        public ProviderUserResponseModel(ProviderUser providerUser, string obj = "providerUser")
            : base(obj)
        {
            if (providerUser == null)
            {
                throw new ArgumentNullException(nameof(providerUser));
            }

            Id          = providerUser.Id.ToString();
            UserId      = providerUser.UserId?.ToString();
            Type        = providerUser.Type;
            Status      = providerUser.Status;
            Permissions = CoreHelpers.LoadClassFromJsonData <Permissions>(providerUser.Permissions);
        }
示例#23
0
        // GET: ProviderUsers/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProviderUser providerUser = db.ProviderUser.Find(id);

            if (providerUser == null)
            {
                return(HttpNotFound());
            }
            return(View(providerUser));
        }
示例#24
0
        // GET: StaticProvider/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProviderUser providerUser = db.Users.FirstOrDefault(x => x.Id == id) as ProviderUser;

            if (providerUser == null)
            {
                return(HttpNotFound());
            }
            return(View(providerUser));
        }
        public ProviderUser Update(ProviderUser providerUser)
        {
            _logger.Debug("Updating provider user with ProviderUserId={0}", providerUser.ProviderUserId);

            UpdateEntityTimestamps(providerUser);

            var dbProviderUser = MapProviderUser(providerUser);

            _getOpenConnection.UpdateSingle(dbProviderUser);

            _logger.Debug("Updated provider user with ProviderUserId={0}", providerUser.ProviderUserId);

            return(MapProviderUser(dbProviderUser));
        }
        public ProviderUser Create(ProviderUser providerUser)
        {
            _logger.Debug("Creating provider user with ProviderUserGuid={0}", providerUser.ProviderUserGuid);

            UpdateEntityTimestamps(providerUser);

            var dbProviderUser = MapProviderUser(providerUser);

            dbProviderUser.ProviderUserId = (int)_getOpenConnection.Insert(dbProviderUser);

            _logger.Debug("Created provider user with ProviderUserGuid={0} and ProviderId={1}",
                          providerUser.ProviderUserGuid, dbProviderUser.ProviderUserId);

            return(MapProviderUser(dbProviderUser));
        }
示例#27
0
        public void RepoEnsureICanAddANewUser()
        {
            List <ProviderUser> emptyDB = new List <ProviderUser>(); //This is the empty database table

            ConnectMocksToDataStore(emptyDB);

            mock_set_users.Setup(i => i.Add(It.IsAny <ProviderUser>())).Callback((ProviderUser s) => emptyDB.Add(s));

            bool added = repo.AddNewUser(test_user);

            ProviderUser stock_user = repo.GetAllUsers().Where(u => u.RealUser.Id == test_user.Id).SingleOrDefault();

            Assert.IsNotNull(stock_user);
            Assert.IsTrue(added);
            Assert.AreEqual(1, repo.GetAllUsers().Count);
        }
        public void ShouldUpdateProviderUserWithGeneratedVerificationCode()
        {
            // Arrange.
            var providerUser = new ProviderUser();

            _mockProviderUserReadRepository
            .Setup(mock => mock.GetByUsername(ValidUsername))
            .Returns(providerUser);

            // Act.
            _strategy.SendEmailVerificationCode(ValidUsername);

            // Assert.
            _mockProviderUserWriteRepository.Verify(mock =>
                                                    mock.Update(providerUser), Times.Once);

            providerUser.EmailVerificationCode.Should().Be(EmailVerificationCode);
        }
        public IHttpActionResult PutProviderUser(ProviderDataDto data)
        {
            ProviderUser user = db.Users.FirstOrDefault(u => u.Email == User.Identity.Name) as ProviderUser;

            if (user == null)
            {
                return(NotFound());
            }

            user.CompanyName = data.CompanyName;
            user.Location    = data.Location;
            user.URL         = data.URL;

            db.Entry(user).State = EntityState.Modified;
            db.SaveChanges();

            return(Ok());
        }
示例#30
0
        public async Task <ProviderUser> GetAccountInfoAsync(string providerToken)
        {
            dynamic result = await GetAsync <dynamic>(providerToken);

            if (result == null)
            {
                throw new Exception("User from this token not exist");
            }

            ProviderUser account = new ProviderUser()
            {
                Email     = result.email,
                FirstName = result.given_name,
                LastName  = result.family_name,
                ImageUrl  = result.picture
            };

            return(account);
        }
示例#31
0
        public async Task <ProviderUser> GetAccountInfoAsync(string providerToken)
        {
            dynamic result = await GetAsync <dynamic>(providerToken, "method/users.get", "v=5.95&fields=photo_100");

            if (result == null)
            {
                throw new Exception("User from this token not exist");
            }

            ProviderUser account = new ProviderUser()
            {
                ProviderId = result["response"].First["id"],
                FirstName  = result["response"].First["first_name"],
                LastName   = result["response"].First["last_name"],
                ImageUrl   = result["response"].First["photo_100"]
            };

            return(account);
        }
示例#32
0
        public async Task <ProviderUser> GetAccountInfoAsync(string providerToken)
        {
            dynamic result = await GetAsync <dynamic>(providerToken, endpoint : "me", args : "fields=first_name,last_name,email,picture.width(100).height(100)");

            if (result == null)
            {
                throw new Exception("User from this token not exist");
            }

            ProviderUser account = new ProviderUser()
            {
                Email     = result.email,
                FirstName = result.first_name,
                LastName  = result.last_name,
                ImageUrl  = result.picture.data.url
            };

            return(account);
        }
示例#33
0
        public static Conversation Create(ProviderUser provideruser)
        {
            Conversation conversation = null;
            lock (lckr)
            {
                // Check if a conversation already exists
                foreach (Conversation c in ConversationManager.conversations)
                {
                    if (provideruser.Uri.CompareTo (c.PeerUser.Uri) == 0) {
                        conversation = c;
                        break;
                    }
                }

                if (conversation == null)
                {
                    Logger.Debug ("Conversation with {0} doesn't exist", provideruser.Uri);
                    conversation = new Conversation (provideruser);
                    conversations.Add (conversation);
                }
            }

            return conversation;
        }
示例#34
0
        internal Conversation(ProviderUser providerUser)
        {
            this.Init (
                AccountManagement.GetAccountByName (providerUser.AccountName),
                providerUser);

            this.initiated = true;
        }
示例#35
0
 /// <summary>
 /// Gets the Person object for a given Jabber ID
 /// </summary>	
 public static Person GetPerson(ProviderUser user)
 {
     return GetPerson(user.Uri);
 }
示例#36
0
        public static bool Exist(ProviderUser peer)
        {
            bool exists = false;
            foreach (Conversation conversation in ConversationManager.conversations)
            {
                if (conversation.PeerUser.Uri.CompareTo (peer.Uri) == 0)
                {
                    exists = true;
                    break;
                }
            }

            return exists;
        }
示例#37
0
        public static Conversation GetExistingConversation(ProviderUser peer)
        {
            Conversation existing = null;
            foreach (Conversation conversation in ConversationManager.conversations)
            {
                if (conversation.PeerUser.Uri.CompareTo (peer.Uri) == 0)
                {
                    existing = conversation;
                    break;
                }
            }

            if (existing == null)
                throw new ApplicationException ("Conversation does not exist");

            return existing;
        }
示例#38
0
文件: Message.cs 项目: GNOME/banter
 public TextMessage(string message, ProviderUser sender)
     : base(message)
 {
     this.Sender = sender;
 }
示例#39
0
        /// <summary>
        /// Creates a new ProviderUser and adds them in one atomic operation
        /// </summary>	
        public static ProviderUser CreateProviderUser(string uri, string protocol, ProviderUserRelationship relationship)
        {
            lock(locker) {
                string key = CreateKey (uri, protocol);

                if (!ProviderUserManager.Instance.users.ContainsKey (key)) {
                    ProviderUser user = new ProviderUser();
                    user.Uri = uri;
                    user.Protocol = protocol;
                    user.Relationship = relationship;
                    ProviderUserManager.Instance.users[key] = user;
                    if (ProviderUserAdded != null)
                        ProviderUserAdded (user);
                    return user;
                }
                else
                    throw new ApplicationException("key already exists");
            }
        }
示例#40
0
        /// <summary>
        /// Constructor for a conversation initiated
        /// from a text channel via a remote user
        /// </summary>
        internal Conversation(
			Account account, 
			ProviderUser providerUser,
			ObjectPath objectpath,
			IChannelText channel)
        {
            this.Init (account, providerUser);

            this.txtChannelObjectPath = objectpath;
            this.initiated = false;

            txtChannel = channel;
            txtChannel.Received += OnReceiveMessageHandler;
            txtChannel.Closed += OnTextChannelClosed;

            AddPendingMessages ();
        }
示例#41
0
文件: Account.cs 项目: GNOME/banter
        /// <summary>
        /// Private method to convert telepathy presence information into
        /// a Banter.Presence object.  The ProviderUser object is updated with
        /// the new presence information which will call all agents registered
        /// for presence update
        /// </summary>
        private void UpdatePresence(ProviderUser user, string presence, string message)
        {
            Banter.Presence banterPresence = new Banter.Presence (Banter.PresenceType.Offline);

            switch (presence)
            {
                case "available":
                    banterPresence.Type = Banter.PresenceType.Available;
                    break;
                case "away":
                case "brb":
                    banterPresence.Type = Banter.PresenceType.Away;
                    break;
                case "busy":
                case "dnd":
                    banterPresence.Type = Banter.PresenceType.Busy;
                    break;
                case "xa":
                    banterPresence.Type = Banter.PresenceType.XA;
                    break;
                case "hidden":
                    banterPresence.Type = Banter.PresenceType.Hidden;
                    break;
                case "offline":
                default:
                    break;
            }

            // Set the message after the type so the message is saved off
            if (message != null && message != String.Empty)
                banterPresence.Message = message;

            /*			Logger.Debug (
                "Updating presence for: {0} to {1}:{2}",
                user.Uri,
                banterPresence.Type.ToString(),
                banterPresence.Message);
            */
            user.Presence = banterPresence;
        }
示例#42
0
 private void Init(Account account, ProviderUser providerUser)
 {
     this.account = account;
     this.tlpConnection = this.account.TlpConnection;
     this.peerUser = providerUser;
     this.callType = CallType.None;
     this.messages = new List<Message> ();
     this.last = 999;
     this.videoStreams = new Dictionary<uint,uint> ();
     this.audioStreams = new Dictionary<uint,uint> ();
     this.peerUser.PresenceUpdated += OnPeerPresenceUpdated;
     this.lastPeerPresence = this.peerUser.Presence;
     this.inRemoveMedia = false;  //hack
 }
示例#43
0
        /// <summary>
        /// Signal called when presence changes for the peer user.
        /// </summary>
        private void OnPeerPresenceUpdated(ProviderUser user)
        {
            string msg;
            Banter.SystemMessage systemMessage = null;

            // no handlers?  exit
            if (MessageReceived == null) return;

            string displayName = (user.Alias != null) ? user.Alias.Split (' ')[0] : user.Uri;
            if (user.Presence.Type == Banter.PresenceType.Offline) {
                msg = String.Format("{0} has gone {1}", displayName, user.Presence.Name);
                systemMessage = new Banter.SystemMessage (msg);
            } else {
                if (user.Presence.Message != null &&
                    user.Presence.Message != String.Empty &&
                    user.Presence.Message != lastPeerPresence.Message) {

                    msg = String.Format(
                            "{0} is {1} \"{2}\"",
                            displayName,
                            user.Presence.Name,
                            user.Presence.Message);
                    systemMessage = new Banter.SystemMessage (msg);

                } else {
                    msg = String.Format("{0} is {1}", displayName, user.Presence.Name);
                    systemMessage = new Banter.SystemMessage (msg);
                }
            }

            lastPeerPresence = user.Presence;

            // Indicate the message to registered handlers
            if (systemMessage != null)
                MessageReceived (this, systemMessage);
        }
示例#44
0
        /// <summary>
        /// Constructor for a conversation initiated
        /// from a media channel via a remote user
        /// </summary>
        internal Conversation(
			Account account, 
			ProviderUser providerUser,
			ObjectPath objectpath,
			IChannelStreamedMedia channel)
        {
            this.Init (account, providerUser);
            this.initiated = false;

            // Figure out the streamed media type
            mediaChannelObjectPath = objectpath;
            mediaChannel = channel;
            mediaChannel.Closed += OnMediaChannelClosed;
            mediaChannel.StreamAdded += OnStreamAdded;
            mediaChannel.StreamDirectionChanged += OnStreamDirectionChanged;
            mediaChannel.StreamError += OnStreamError;
            mediaChannel.StreamRemoved += OnStreamRemoved;
            mediaChannel.StreamStateChanged += OnStreamStateChanged;
            mediaChannel.MembersChanged += OnMembersChanged;
        }
示例#45
0
 /// <summary>
 /// Adds the ProviderUser for the given key
 /// The key is basically "Uri:Provider"
 /// </summary>	
 public static void AddProviderUser(string key, ProviderUser user)
 {
     lock(locker) {
         if(!ProviderUserManager.Instance.users.ContainsKey(key)) {
             ProviderUserManager.Instance.users[key] = user;
             if(ProviderUserAdded != null)
                 ProviderUserAdded(user);
         }
         else {
             throw new ApplicationException("key already exists");
         }
     }
 }