Esempio n. 1
0
        /// <summary>
        /// Notify application when the contact state has changed.
        /// Application may then query the contact info to get the details.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _pjContact_OnBuddyState(object sender, EventArgs e)
        {
            ContactInfo contactInfo = new ContactInfo();

            contactInfo.PresenceStatus = new PresenceStatus();

            // Get the contact info.
            using (pjsua2.BuddyInfo pjContactInfo = _pjContact.getInfo())
            {
                contactInfo.Info = pjContactInfo.contact;
                contactInfo.PresMonitorEnabled = pjContactInfo.presMonitorEnabled;
                contactInfo.SubState           = OnMwiInfoParam.GetSubscriptionState(pjContactInfo.subState);
                contactInfo.SubStateName       = pjContactInfo.subStateName;
                contactInfo.SubTermCode        = AccountInfo.GetStatusCodeEx(pjContactInfo.subTermCode);
                contactInfo.SubTermReason      = pjContactInfo.subTermReason;
                contactInfo.Uri = pjContactInfo.uri;

                if (pjContactInfo.presStatus != null)
                {
                    contactInfo.PresenceStatus.Activity   = PresenceStatus.GetActivityEx(pjContactInfo.presStatus.activity);
                    contactInfo.PresenceStatus.Note       = pjContactInfo.presStatus.note;
                    contactInfo.PresenceStatus.RpidId     = pjContactInfo.presStatus.rpidId;
                    contactInfo.PresenceStatus.Status     = PresenceStatus.GetContactStatusEx(pjContactInfo.presStatus.status);
                    contactInfo.PresenceStatus.StatusText = pjContactInfo.presStatus.statusText;
                }
            }

            // Invoke the call back event.
            OnContactState?.Invoke(this, contactInfo);
        }
Esempio n. 2
0
        /// <summary>
        /// Get detailed contact info.
        /// </summary>
        /// <returns>The contact info.</returns>
        public ContactInfo GetInfo()
        {
            // If contact created.
            if (_created)
            {
                // Get the contact info.
                using (pjsua2.BuddyInfo pjContactInfo = _pjContact.getInfo())
                {
                    ContactInfo contactInfo = new ContactInfo();
                    contactInfo.Info = pjContactInfo.contact;
                    contactInfo.PresMonitorEnabled = pjContactInfo.presMonitorEnabled;
                    contactInfo.SubState           = OnMwiInfoParam.GetSubscriptionState(pjContactInfo.subState);
                    contactInfo.SubStateName       = pjContactInfo.subStateName;
                    contactInfo.SubTermCode        = AccountInfo.GetStatusCodeEx(pjContactInfo.subTermCode);
                    contactInfo.SubTermReason      = pjContactInfo.subTermReason;
                    contactInfo.Uri = pjContactInfo.uri;

                    if (pjContactInfo.presStatus != null)
                    {
                        contactInfo.PresenceStatus            = new PresenceStatus();
                        contactInfo.PresenceStatus.Activity   = PresenceStatus.GetActivityEx(pjContactInfo.presStatus.activity);
                        contactInfo.PresenceStatus.Note       = pjContactInfo.presStatus.note;
                        contactInfo.PresenceStatus.RpidId     = pjContactInfo.presStatus.rpidId;
                        contactInfo.PresenceStatus.Status     = PresenceStatus.GetContactStatusEx(pjContactInfo.presStatus.status);
                        contactInfo.PresenceStatus.StatusText = pjContactInfo.presStatus.statusText;
                    }

                    // Return the contact info.
                    return(contactInfo);
                }
            }
            else
            {
                throw new Exception(CreateContact);
            }
        }