Example #1
0
        public void UpdateLocation(string uriWithTag, PresenceStatus status, string message)
        {
            PresenceLocation item;

            if (!_locations.ContainsKey(uriWithTag))
            {
                if (status != PresenceStatus.Unavailable)
                {
                    item = new PresenceLocation(uriWithTag)
                    {
                        CurrentPresence = new Presence(status, message),
                        Subscription    = this
                    };
                    _locations[item.Key] = item;
                }
            }
            else
            {
                item = (PresenceLocation)_locations[uriWithTag];
                item.CurrentPresence = new Presence(status, message);
                if (status == PresenceStatus.Unavailable)
                {
                    _locations.Remove(uriWithTag);
                }
            }
        }
Example #2
0
 public Contact()
 {
     this.presenceStatus   = PresenceStatus.Offline;
     this.groupName        = SpecialNames.SHARED_DOUBANGO;
     this.authorization    = Authorization.UnKnown;
     this.hyperAvaiability = DateTime.Now;
 }
Example #3
0
        public void SetPresence(PresenceStatus statu)
        {
            SipMessage sipPacket = PacketFactory.SetPresence(statu);

            this.convSetPresence         = this.convMgr.Create(sipPacket, true);
            this.convSetPresence.MsgRcv += new EventHandler <ConversationArgs>(convSetPresence_MsgRcv);
        }
Example #4
0
        protected virtual void OnDisconnected(EventArgs e)
        {
            Trace.Call(e);

            var msg = CreateMessageBuilder();

            msg.AppendEventPrefix();
            msg.AppendText(_("Disconnected from {0}"), NetworkID);
            Session.AddMessageToChat(Chat, msg.ToMessage());

            _PresenceStatus = PresenceStatus.Offline;

            Session.UpdateNetworkStatus();

            if (Disconnected != null)
            {
                Disconnected(this, e);
            }

            var hooks = new HookRunner("engine", "protocol-manager", "on-disconnected");

            hooks.Environments.Add(new ChatHookEnvironment(Chat));
            hooks.Environments.Add(new ProtocolManagerHookEnvironment(this));

            var cmdChar = (string)Session.UserConfig["Interface/Entry/CommandCharacter"];

            hooks.Commands.Add(new SessionHookCommand(Session, Chat, cmdChar));
            hooks.Commands.Add(new ProtocolManagerHookCommand(this, Chat, cmdChar));

            // show time
            hooks.Init();
            hooks.Run();
        }
Example #5
0
 public UserStatusChanged(string hubId, Guid userId, PresenceStatus status)
 {
     HubId     = hubId;
     UserId    = userId;
     Status    = status;
     Timestamp = DateTime.UtcNow;
 }
Example #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (PresenceStatus != global::AcFunDanmu.RegisterRequest.Types.PresenceStatus.KPresenceOffline)
            {
                hash ^= PresenceStatus.GetHashCode();
            }
            if (AppActiveStatus != global::AcFunDanmu.RegisterRequest.Types.ActiveStatus.KInvalid)
            {
                hash ^= AppActiveStatus.GetHashCode();
            }
            if (pushServiceToken_ != null)
            {
                hash ^= PushServiceToken.GetHashCode();
            }
            hash ^= pushServiceTokenList_.GetHashCode();
            if (KeepaliveIntervalSec != 0)
            {
                hash ^= KeepaliveIntervalSec.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #7
0
        public override void SetPresenceStatus(PresenceStatus status,
                                               string message)
        {
            Trace.Call(status, message);

            // TODO: implement me
        }
 private void ChangeStatusAction(PresenceStatus status)
 {
     if (status != Status)
     {
         Status = status;
         _logicClient.SendPing(Status);
     }
 }
Example #9
0
 public void setOnlineStatus(PresenceStatus pres_st)
 {
     pjsua2PINVOKE.Account_setOnlineStatus(swigCPtr, PresenceStatus.getCPtr(pres_st));
     if (pjsua2PINVOKE.SWIGPendingException.Pending)
     {
         throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #10
0
 public bool PresencePublish(PresenceStatus status)
 {
     if (this.IsPublicationEnabled)
     {
         return(this.PublishPresence(status));
     }
     return(false);
 }
Example #11
0
 public PresenceStatusChangedEventArgs(PresenceStatus oldStatus,
                                       PresenceStatus newStatus,
                                       string newMessage)
 {
     OldStatus  = oldStatus;
     NewStatus  = newStatus;
     NewMessage = newMessage;
 }
Example #12
0
    private void UpdateInfo(Vector2 coords, string realmServerName, string realmLayerName, PresenceStatus status)
    {
        currentCoords          = coords;
        currentRealmServerName = realmServerName;
        currentRealmLayerName  = realmLayerName;
        currentPresenceStatus  = status;

        RefreshInfo();
    }
Example #13
0
        public void SendPing(PresenceStatus status)
        {
            var presenceNotification = new PresenceStatusNotification {
                Login = Login, PresenceStatus = status
            };

            _queueClientService.SendData(_configurationService.MainQueueName, RouteKey,
                                         _configurationService.ExchangeName, presenceNotification);
        }
    void RequestCreateFriendEntry(string id, string name, PresenceStatus status = PresenceStatus.ONLINE)
    {
        var model1 = new FriendEntry.Model()
        {
            status   = status,
            userName = name,
        };

        controller.view.friendsList.CreateOrUpdateEntryDeferred(id, model1);
    }
Example #15
0
        private void comboBoxStatus_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PresenceStatus status = (this.comboBoxStatus.SelectedValue as Status).Value;

            this.configurationService.Set(Configuration.ConfFolder.RCS, Configuration.ConfEntry.STATUS, status.ToString());

            if (this.sipService.IsPublicationEnabled)
            {
                this.sipService.PresencePublish(status);
            }
        }
Example #16
0
 public async Task SetCurrentPresence(PresenceStatus presence)
 {
     if (presence == null)
     {
         throw new ArgumentNullException("value");
     }
     using (var context = CreateContext()) {
         (await GetUser(context)).CurrentPresenceData = presence;
         await context.MySaveChanges();
     }
 }
Example #17
0
        public ContactStatusChangedEventArgs(Contact contact, Contact via,
                                             PresenceStatus oldStatus, PresenceStatus newStatus)
            : base(oldStatus, newStatus)
        {
            this.contact = contact;
            this.via     = via;

            if (via == null && contact != null)
            {
                via = contact.Via;
            }
        }
Example #18
0
 private bool PublishPresence(PresenceStatus status)
 {
     if (this.pubPres != null)
     {
         if (status == PresenceStatus.HyperAvailable)
         {
             this.pubPres.HyperAvailabilityTimeout = this.StartHyperAvailabilityTimer();
         }
         return(this.pubPres.Publish(status));
     }
     return(false);
 }
 public bool Publish(PresenceStatus status)
 {
     this.presenceStatus = status;
     if (this.PartialPublication)
     {
         return(false);
     }
     else
     {
         return(this.PublishFullState());
     }
 }
Example #20
0
    FriendEntry CreateFriendEntry(string id, string name, PresenceStatus status = PresenceStatus.ONLINE)
    {
        var model1 = new FriendEntry.Model()
        {
            status   = status,
            userName = name,
        };

        controller.view.friendsList.CreateOrUpdateEntry(id, model1);

        return(controller.view.friendsList.GetEntry(id) as FriendEntry);
    }
Example #21
0
        public virtual void SetPresenceStatus(PresenceStatus status,
                                              string message)
        {
            var args = new PresenceStatusChangedEventArgs(_PresenceStatus,
                                                          status, message);

            _PresenceStatus = status;

            if (args.OldStatus != args.NewStatus)
            {
                OnPresenceStatusChanged(args);
            }
        }
Example #22
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (appInfo_ != null)
            {
                hash ^= AppInfo.GetHashCode();
            }
            if (deviceInfo_ != null)
            {
                hash ^= DeviceInfo.GetHashCode();
            }
            if (envInfo_ != null)
            {
                hash ^= EnvInfo.GetHashCode();
            }
            if (PresenceStatus != global::AcFunDanmu.RegisterRequest.Types.PresenceStatus.KPresenceOffline)
            {
                hash ^= PresenceStatus.GetHashCode();
            }
            if (AppActiveStatus != global::AcFunDanmu.RegisterRequest.Types.ActiveStatus.KInvalid)
            {
                hash ^= AppActiveStatus.GetHashCode();
            }
            if (AppCustomStatus.Length != 0)
            {
                hash ^= AppCustomStatus.GetHashCode();
            }
            if (pushServiceToken_ != null)
            {
                hash ^= PushServiceToken.GetHashCode();
            }
            if (InstanceId != 0L)
            {
                hash ^= InstanceId.GetHashCode();
            }
            hash ^= pushServiceTokenList_.GetHashCode();
            if (KeepaliveIntervalSec != 0)
            {
                hash ^= KeepaliveIntervalSec.GetHashCode();
            }
            if (ztCommonInfo_ != null)
            {
                hash ^= ZtCommonInfo.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #23
0
        public static SipMessage SetPresence(PresenceStatus statu)
        {
            string       msgContent = string.Format(string.Format("<args><presence><basic value=\"{0}\" /></presence></args>", (int)statu));
            SipRequest   req        = new SipRequest(SipMethodName.Service, DEFAULT_URI);
            SipHeadField hFrom      = new SipHeadField(SipHeadFieldName.From, Ower.Uri.Sid.ToString());
            SipHeadField hCallID    = new SipHeadField(SipHeadFieldName.CallID, Ower.Conncetion.NextCallID().ToString());
            SipHeadField hCSeq      = new SipHeadField(SipHeadFieldName.CSeq, "1 " + SipMethodName.Service);
            SipHeadField hEvent     = new SipHeadField(SipHeadFieldName.Event, "SetPresence");

            req.HeadFields.Add(hFrom);
            req.HeadFields.Add(hCallID);
            req.HeadFields.Add(hCSeq);
            req.HeadFields.Add(hEvent);
            req.Body = msgContent;
            return(req);
        }
Example #24
0
        private bool BroadcastingAllowed(PresenceStatus presenceStatus)
        {
            bool broadcastingAllowed = false;

            switch (presenceStatus)
            {
            case PresenceStatus.Online:
            case PresenceStatus.Away:
            case PresenceStatus.BRB:
            case PresenceStatus.Idle:
            case PresenceStatus.Phone:
            case PresenceStatus.Unknown:
                broadcastingAllowed = true;
                break;
            }
            return(broadcastingAllowed);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Cursor = System.Windows.Input.Cursors.Wait;

            //this.imageAvatar.Source = MyImageConverter.FromBitmap(Properties.Resources.avatar_48);
            //this.labelFreeText.Content = this.configurationService.Get(Configuration.ConfFolder.RCS, Configuration.ConfEntry.FREE_TEXT, Configuration.DEFAULT_RCS_FREE_TEXT);
            string strName = this.configurationService.Get(Configuration.ConfFolder.IDENTITY, Configuration.ConfEntry.DISPLAY_NAME, Configuration.DEFAULT_IDENTITY_DISPLAY_NAME);

            if (strName != "John Doe")
            {
                //this.labelDisplayName.Content = strName;
            }

            if (System.IO.File.Exists(MainWindow.AVATAR_PATH))
            {
                //this.imageAvatar.Source = new ImageSourceConverter().ConvertFromInvariantString(MainWindow.AVATAR_PATH) as ImageSource;
            }


            Status[] statues = new Status[]
            {
                new Status("Online", PresenceStatus.Online, "/BogheApp;component/embedded/16/user_16.png"),
                new Status("Busy", PresenceStatus.Busy, "/BogheApp;component/embedded/16/user_busy_16.png"),
                new Status("Be Right Back", PresenceStatus.BeRightBack, "/BogheApp;component/embedded/16/user_back16.png"),
                new Status("Away", PresenceStatus.Away, "/BogheApp;component/embedded/16/user_time_16.png"),
                new Status("On The Phone", PresenceStatus.OnThePhone, "/BogheApp;component/embedded/16/user_onthephone_16.png"),
                new Status("HyperAvailable", PresenceStatus.HyperAvailable, "/BogheApp;component/embedded/16/user_hyper_avail_16.png"),
                new Status("Offline", PresenceStatus.Offline, "/BogheApp;component/embedded/16/user_offline_16.png")
            };
            PresenceStatus status = (PresenceStatus)Enum.Parse(typeof(PresenceStatus),
                                                               this.configurationService.Get(Configuration.ConfFolder.RCS, Configuration.ConfEntry.STATUS, Configuration.DEFAULT_RCS_STATUS.ToString()));
            int statusIndex = statues.ToList().FindIndex(x => x.Value == status);

            //this.registrations.CollectionChanged += (_sender, _e) =>
            //{
            //    this.MenuItemFile_Registrations.Header = String.Format("Registrations ({0})", this.registrations.Count);
            //};
            this.watchers.CollectionChanged += (_sender, _e) =>
            {
                //this.MenuItemEAB_Authorizations.Header = String.Format("Authorizations ({0})", this.watchers.Count);
            };

            this.Cursor = System.Windows.Input.Cursors.Arrow;

            table1_MouseLeftButtonDown(null, null);
        }
        private string getStatusImage(PresenceStatus status)
        {
            switch (status)
            {
            case PresenceStatus.Online:
            {
                return(ImageOnline);
            }

            case PresenceStatus.Afk:
            {
                return(ImageAfk);
            }
            }

            return(ImageOffline);
        }
Example #27
0
        void OnAccountStateChanged(int accState)
        {
            Logger.LogNotice($"Registration state changed from {_registrationState} to {accState}");
            _registrationState = accState;

            RaiseRegistrationStateChanged();

            if (RegisterState == SipAccountState.Online &&
                (PresenceStatus.Code == PresenceStatusCode.Unknown || PresenceStatus.Code == PresenceStatusCode.Offline))
            {
                PresenceStatus = new PresenceStatus(PresenceStatusCode.Available);
            }

            if (RegisterState == SipAccountState.Offline && PresenceStatus.Code != PresenceStatusCode.Offline)
            {
                PresenceStatus = new PresenceStatus(PresenceStatusCode.Offline);
            }
        }
Example #28
0
        internal override void UpdateFromDocument(JObject doc)
        {
            _userId = doc["user"]["id"].ToObject <string>();
            switch (doc["status"].ToObject <string>())
            {
            case "online":
                Status = PresenceStatus.Online; break;

            case "idle":
                Status = PresenceStatus.Idle; break;

            case "dnd":
                Status = PresenceStatus.DoNotDisturb; break;

            default:
                Status = PresenceStatus.Offline; break;
            }
        }
Example #29
0
        protected virtual void OnDisconnected(EventArgs e)
        {
            Trace.Call(e);

            var msg = CreateMessageBuilder();

            msg.AppendEventPrefix();
            msg.AppendText(_("Disconnected from {0}"), NetworkID);
            Session.AddMessageToChat(Chat, msg.ToMessage());

            _PresenceStatus = PresenceStatus.Offline;

            Session.UpdateNetworkStatus();

            if (Disconnected != null)
            {
                Disconnected(this, e);
            }
        }
Example #30
0
 private void RefreshBotPersonalMessage()
 {
     if (_messenger.Owner != null)
     {
         string         message = "Idle";
         PresenceStatus status  = PresenceStatus.Online;
         using (ControlServiceAgent tvControlAgent = new ControlServiceAgent())
         {
             ActiveRecording[] activeRecordings = tvControlAgent.GetActiveRecordings();
             if (activeRecordings.Length > 0)
             {
                 message = "Recording";
                 status  = PresenceStatus.Busy;
             }
             else
             {
                 LiveStream[] liveStreams = tvControlAgent.GetLiveStreams();
                 if (liveStreams.Length > 0)
                 {
                     message = "Streaming";
                     status  = PresenceStatus.Away;
                 }
                 else
                 {
                     UpcomingRecording upcomingRecording = tvControlAgent.GetNextUpcomingRecording(false);
                     if (upcomingRecording != null)
                     {
                         message = "Waiting for next scheduled recording";
                     }
                 }
             }
         }
         if (_messenger.Owner.PersonalMessage == null ||
             _messenger.Owner.PersonalMessage.Message != message)
         {
             _messenger.Owner.PersonalMessage = new PersonalMessage(message);
         }
         if (_messenger.Owner.Status != status)
         {
             _messenger.Owner.Status = status;
         }
     }
 }
Example #31
0
        void Owner_StatusChanged(object sender, StatusChangedEventArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new EventHandler<StatusChangedEventArgs>(Owner_StatusChanged), new object[] { sender, e });
                return;
            }

            if (messenger.Nameserver.IsSignedIn)
            {
                if (Messenger.Owner.Online)
                {
                    lastStatus = Messenger.Owner.Status;
                }

                comboStatus.SelectedIndex = comboStatus.FindString(GetStatusString(Messenger.Owner.Status));
            }
        }
Example #32
0
        public override void SetPresenceStatus(PresenceStatus status,
                                               string message)
        {
            Trace.Call(status, message);

            if (!_IrcClient.IsConnected) {
                return;
            }

            switch (status) {
                case PresenceStatus.Online:
                    _IrcClient.RfcAway();
                    break;
                case PresenceStatus.Away:
                    if (String.IsNullOrEmpty(message)) {
                        // HACK: empty away message unsets away state on IRC
                        message = "away";
                    }
                    _IrcClient.RfcAway(message);
                    break;
            }
        }
Example #33
0
 public override void SetPresenceStatus(PresenceStatus status, string message)
 {
     throw new System.NotImplementedException();
 }
Example #34
0
        /// <summary>
        /// Set the <see cref="Status"/> and fire <see cref="Contact.StatusChanged"/> ,
        /// <see cref="Contact.ContactOnline"/> and <see cref="Contact.ContactOffline"/> event.
        /// </summary>
        /// <param name="newStatus"></param>
        internal void SetStatus(PresenceStatus newStatus)
        {
            //Becareful deadlock!

            PresenceStatus currentStatus = PresenceStatus.Unknown;

            lock (syncObject)
            {
                currentStatus = status;
            }

            if (currentStatus != newStatus)
            {
                PresenceStatus oldStatus = currentStatus;

                lock (syncObject)
                {

                    status = newStatus;
                }

                // raise an event
                OnStatusChanged(new StatusChangedEventArgs(oldStatus, newStatus));

                // raise the online/offline events
                if (oldStatus == PresenceStatus.Offline)
                    OnContactOnline(new StatusChangedEventArgs(oldStatus, newStatus));

                if (newStatus == PresenceStatus.Offline)
                    OnContactOffline(new StatusChangedEventArgs(oldStatus, newStatus));
            }
        }
Example #35
0
        internal void RemoveFromList(RoleLists list)
        {
            if ((lists & list) != RoleLists.None)
            {
                lists ^= list;

                // set this contact to offline when it is neither on the allow list or on the forward list
                if (!(OnForwardList || OnAllowedList))
                {
                    status = PresenceStatus.Offline;
                    //also clear the groups, becase msn loose them when removed from the two lists
                    contactGroups.Clear();
                }

                NotifyManager();
            }
        }
Example #36
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PresenceStatus obj)
 {
     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
Example #37
0
        public override void SetPresenceStatus(PresenceStatus status,
                                               string message)
        {
            Trace.Call(status, message);

            // TODO: implement me
        }
Example #38
0
        public override void SetPresenceStatus(PresenceStatus status,
                                               string message)
        {
            Trace.Call(status, message);

            if (!IsConnected) {
                return;
            }

            switch (status) {
                case PresenceStatus.Online:
                    JabberClient.Show = ShowType.NONE;
                    JabberClient.Priority = Server.Priorities[status];
                    JabberClient.Status = message;
                    break;
                case PresenceStatus.Away:
                    JabberClient.Priority = Server.Priorities[status];
                    JabberClient.Show = ShowType.away;
                    JabberClient.Status = message;
                    break;
            }

            JabberClient.SendMyPresence();

            base.SetPresenceStatus(status, message);
        }
Example #39
0
        public override void SetPresenceStatus(PresenceStatus status,
                                               string message)
        {
            Trace.Call(status, message);

            if (!IsConnected) {
                return;
            }

            switch (status) {
                case PresenceStatus.Online:
                    JabberClient.Show = ShowType.NONE;
                    JabberClient.Priority = Server.Priorities[status];
                    JabberClient.Status = message;
                    break;
                case PresenceStatus.Away:
                    JabberClient.Priority = Server.Priorities[status];
                    JabberClient.Show = ShowType.away;
                    JabberClient.Status = message;
                    break;
            }

            JabberClient.SendMyPresence();

            // send presence update to all MUCs, see XEP-0045:
            // http://xmpp.org/extensions/xep-0045.html#changepres
            foreach (var chat in Chats) {
                if (!(chat is XmppGroupChatModel)) {
                    continue;
                }
                var muc = (XmppGroupChatModel) chat;

                var to = new Jid(muc.ID) {
                    Resource = muc.OwnNickname
                };

                var presence = new Presence() {
                    Show = JabberClient.Show,
                    Status = JabberClient.Status,
                    From = JabberClient.MyJID,
                    To = to
                };

                if (JabberClient.EnableCapabilities) {
                    presence.AddChild(JabberClient.Capabilities);
                }
                JabberClient.Send(presence);
            }

            base.SetPresenceStatus(status, message);
        }
Example #40
0
            public static int GetContactStatusImageIndex(PresenceStatus status)
            {
                switch (status)
                {
                    case PresenceStatus.Online:
                        return Online;

                    case PresenceStatus.Busy:
                    case PresenceStatus.Phone:
                        return Busy;

                    case PresenceStatus.BRB:
                    case PresenceStatus.Away:
                    case PresenceStatus.Lunch:
                        return Away;

                    case PresenceStatus.Idle:
                        return Idle;
                    case PresenceStatus.Hidden:
                        return Hidden;

                    case PresenceStatus.Offline:
                        return Offline;

                    default:
                        return Offline;
                }
            }
Example #41
0
            public static int GetCircleStatusImageIndex(PresenceStatus status)
            {
                switch (status)
                {
                    case PresenceStatus.Online:
                        return CircleOnline;
                    case PresenceStatus.Offline:
                        return CircleOffline;
                }

                return CircleOffline;
            }
Example #42
0
        protected virtual void OnDisconnected(EventArgs e)
        {
            Trace.Call(e);

            var msg = CreateMessageBuilder();
            msg.AppendEventPrefix();
            msg.AppendText(_("Disconnected from {0}"), NetworkID);
            Session.AddMessageToChat(Chat, msg.ToMessage());

            _PresenceStatus = PresenceStatus.Offline;

            Session.UpdateNetworkStatus();

            if (Disconnected != null) {
                Disconnected(this, e);
            }
        }
Example #43
0
        private List<string> GetContacts(PresenceStatus status)
        {
            List<string> contacts = new List<string>();

            foreach (Contact contact in _messenger.ContactList.All)
            {
                if (contact.Status == status)
                {
                    contacts.Add(Regex.Replace(contact.Name, @"[^A-Za-z0-9]", ""));
                }
            }

            return contacts;
        }
Example #44
0
 public bool PresencePublish(PresenceStatus status)
 {
     if (this.IsPublicationEnabled)
     {
         return this.PublishPresence(status);
     }
     return false;
 }
Example #45
0
 public bool Publish(PresenceStatus status)
 {
     this.presenceStatus = status;
     if (this.PartialPublication)
     {
         return false;
     }
     else
     {
         return this.PublishFullState();
     }
 }
Example #46
0
        private string GetStatusString(PresenceStatus status)
        {
            switch (status)
            {
                case PresenceStatus.Away:
                case PresenceStatus.BRB:
                case PresenceStatus.Lunch:
                case PresenceStatus.Idle:
                    return "Away";
                case PresenceStatus.Online:
                    return "Online";
                case PresenceStatus.Offline:
                    return "Offline";
                case PresenceStatus.Hidden:
                    return "Hidden";
                case PresenceStatus.Busy:
                case PresenceStatus.Phone:
                    return "Busy";

            }

            return "Offline";
        }
Example #47
0
        public override void SetPresenceStatus(PresenceStatus status,
                                               string message)
        {
            Trace.Call(status, message);

            if (!IsConnected || !JabberClient.IsAuthenticated) {
                return;
            }

            PresenceType? xmppType = null;
            string xmppShow = null;
            switch (status) {
                case PresenceStatus.Online:
                    xmppType = PresenceType.available;
                    JabberClient.Priority = Server.Priorities[status];
                    break;
                case PresenceStatus.Away:
                    xmppType = PresenceType.available;
                    JabberClient.Priority = Server.Priorities[status];
                    xmppShow = "away";
                    break;
                case PresenceStatus.Offline:
                    xmppType = PresenceType.unavailable;
                    break;
            }
            if (xmppType == null) {
                return;
            }

            JabberClient.Presence(xmppType.Value, message, xmppShow,
                                  JabberClient.Priority);
        }
Example #48
0
 public override void SetPresenceStatus(PresenceStatus status, string message)
 {
 }
Example #49
0
        /// <summary>
        /// Translates MSNStatus enumeration to messenger's textual status presentation.
        /// </summary>
        /// <param name="status">MSNStatus enum object representing the status to translate</param>
        /// <returns>The corresponding textual value</returns>
        protected internal static string ParseStatus(PresenceStatus status)
        {
            switch (status)
            {
                case PresenceStatus.Online:
                    return "NLN";

                case PresenceStatus.Busy:
                case PresenceStatus.Phone:
                    return "BSY";

                case PresenceStatus.Idle:
                    return "IDL";

                case PresenceStatus.BRB:
                case PresenceStatus.Away:
                case PresenceStatus.Lunch:
                    return "AWY";

                case PresenceStatus.Offline:
                    return "FLN";

                case PresenceStatus.Hidden:
                    return "HDN";

                default:
                    break;
            }

            return "Unknown status";
        }
Example #50
0
 public void SetPresenceStatus(PresenceStatus status, string message)
 {
 }
Example #51
0
 private bool PublishPresence(PresenceStatus status)
 {
     if (this.pubPres != null)
     {
         if (status == PresenceStatus.HyperAvailable)
         {
             this.pubPres.HyperAvailabilityTimeout = this.StartHyperAvailabilityTimer();
         }
         return this.pubPres.Publish(status);
     }
     return false;
 }
Example #52
0
 public void setOnlineStatus(PresenceStatus pres_st)
 {
     pjsua2PINVOKE.Account_setOnlineStatus(swigCPtr, PresenceStatus.getCPtr(pres_st));
     if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve();
 }
Example #53
0
        private void comboStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new EventHandler(comboStatus_SelectedIndexChanged), sender, e);
                return;
            }

            PresenceStatus newstatus = (PresenceStatus)Enum.Parse(typeof(PresenceStatus), comboStatus.Text);

            if (messenger.Connected)
            {
                if (newstatus == PresenceStatus.Offline)
                {
                    foreach (ConversationForm convform in ConversationForms)
                    {
                        if (convform.Visible == true)
                        {
                            if (MessageBox.Show("You are signing out from example client. All windows will be closed.", "Sign out", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                            {
                                return;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    Messenger.Disconnect();
                }
                else
                {
                    Messenger.Owner.Status = newstatus;
                    lastStatus = newstatus;
                }
            }
            else if (newstatus == PresenceStatus.Offline)
            {
                SetLastStatusCombo();
            }
            else
            {
                lastStatus = newstatus;
            }
        }
Example #54
0
        public override void SetPresenceStatus(PresenceStatus status,
                                               string message)
        {
            Trace.Call(status, message);

            // TODO: implement me

            // should we send updates here?!?
        }
        /// <summary>
        /// Set the status of the contact list owner (the client).
        /// </summary>
        /// <remarks>You can only set the status _after_ SignedIn event. Otherwise you won't receive online notifications from other clients or the connection is closed by the server.</remarks>
        internal void SetPresenceStatus(
            PresenceStatus newStatus,
            ClientCapabilities newLocalIMCaps, ClientCapabilitiesEx newLocalIMCapsex,
            ClientCapabilities newLocalPECaps, ClientCapabilitiesEx newLocalPECapsex,
            string newEPName,
            PersonalMessage newPSM,
            bool forcePEservice)
        {
            if (IsSignedIn == false)
                throw new MSNPSharpException("Can't set status. You must wait for the SignedIn event before you can set an initial status.");

            if (newStatus == PresenceStatus.Offline)
            {
                SignoutFrom(MachineGuid);
                return;
            }

            bool setAll = (Owner.Status == PresenceStatus.Offline);

            if (setAll || forcePEservice ||
                newStatus != Owner.Status ||
                newLocalIMCaps != Owner.LocalEndPointIMCapabilities ||
                newLocalIMCapsex != Owner.LocalEndPointIMCapabilitiesEx ||
                newLocalPECaps != Owner.LocalEndPointPECapabilities ||
                newLocalPECapsex != Owner.LocalEndPointPECapabilitiesEx ||
                newEPName != Owner.EpName)
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlElement userElement = xmlDoc.CreateElement("user");

                // s.IM (Status, CurrentMedia)
                if (setAll || forcePEservice ||
                    newStatus != Owner.Status)
                {
                    XmlElement service = xmlDoc.CreateElement("s");
                    service.SetAttribute("n", ServiceShortNames.IM.ToString());
                    service.InnerXml =
                        "<Status>" + ParseStatus(newStatus) + "</Status>" +
                        "<CurrentMedia>" + MSNHttpUtility.XmlEncode(newPSM.CurrentMedia) + "</CurrentMedia>";

                    userElement.AppendChild(service);

                    // Don't call Owner.Status = newStatus.
                }

                // s.PE (UserTileLocation, FriendlyName, PSM, Scene, ColorScheme)
                if (setAll ||
                    forcePEservice)
                {
                    XmlElement service = xmlDoc.CreateElement("s");
                    service.SetAttribute("n", ServiceShortNames.PE.ToString());
                    service.InnerXml = newPSM.Payload;
                    userElement.AppendChild(service);

                    // Don't set owner.PersonalMessage here. It is replaced (with a new reference) when NFY PUT received.
                }

                // sep.IM (Capabilities)
                if (setAll ||
                    newLocalIMCaps != Owner.LocalEndPointIMCapabilities ||
                    newLocalIMCapsex != Owner.LocalEndPointIMCapabilitiesEx)
                {
                    ClientCapabilities localIMCaps = setAll ? ClientCapabilities.DefaultIM : newLocalIMCaps;
                    ClientCapabilitiesEx localIMCapsEx = setAll ? ClientCapabilitiesEx.DefaultIM : newLocalIMCapsex;

                    XmlElement sep = xmlDoc.CreateElement("sep");
                    sep.SetAttribute("n", ServiceShortNames.IM.ToString());
                    XmlElement capabilities = xmlDoc.CreateElement("Capabilities");
                    capabilities.InnerText = ((long)localIMCaps).ToString() + ":" + ((long)localIMCapsEx).ToString();
                    sep.AppendChild(capabilities);
                    userElement.AppendChild(sep);

                    // Don't call Owner.LocalEndPointIMCapabilities. It is recursive call to this method.
                }

                // sep.PE (Capabilities)
                if (setAll ||
                    newLocalPECaps != Owner.LocalEndPointPECapabilities ||
                    newLocalPECapsex != Owner.LocalEndPointPECapabilitiesEx)
                {
                    ClientCapabilities localPECaps = setAll ? ClientCapabilities.DefaultPE : newLocalPECaps;
                    ClientCapabilitiesEx localPECapsEx = setAll ? ClientCapabilitiesEx.DefaultPE : newLocalPECapsex;

                    XmlElement sep = xmlDoc.CreateElement("sep");
                    sep.SetAttribute("n", ServiceShortNames.PE.ToString());
                    XmlElement VER = xmlDoc.CreateElement("VER");
                    VER.InnerText = Credentials.ClientInfo.MessengerClientName + ":" + Credentials.ClientInfo.MessengerClientBuildVer;
                    sep.AppendChild(VER);
                    XmlElement TYP = xmlDoc.CreateElement("TYP");
                    TYP.InnerText = "1";
                    sep.AppendChild(TYP);
                    XmlElement capabilities = xmlDoc.CreateElement("Capabilities");
                    capabilities.InnerText = ((long)localPECaps).ToString() + ":" + ((long)localPECapsEx).ToString();
                    sep.AppendChild(capabilities);
                    userElement.AppendChild(sep);

                    // Don't call Owner.LocalEndPointPECapabilities. It is recursive call to this method.
                }

                // sep.PD (EpName, State)
                if (setAll ||
                    newEPName != Owner.EpName ||
                    newStatus != Owner.Status)
                {
                    XmlElement sep = xmlDoc.CreateElement("sep");
                    sep.SetAttribute("n", ServiceShortNames.PD.ToString());
                    XmlElement clientType = xmlDoc.CreateElement("ClientType");
                    clientType.InnerText = "1";
                    sep.AppendChild(clientType);
                    XmlElement epName = xmlDoc.CreateElement("EpName");
                    epName.InnerText = MSNHttpUtility.XmlEncode(newEPName);
                    sep.AppendChild(epName);
                    XmlElement idle = xmlDoc.CreateElement("Idle");
                    idle.InnerText = ((newStatus == PresenceStatus.Idle) ? "true" : "false");
                    sep.AppendChild(idle);
                    XmlElement state = xmlDoc.CreateElement("State");
                    state.InnerText = ParseStatus(newStatus);
                    sep.AppendChild(state);
                    userElement.AppendChild(sep);

                    // Don't set Owner.EpName. It is recursive call to this method.
                }

                if (userElement.HasChildNodes)
                {
                    string xml = userElement.OuterXml;
                    string me = ((int)Owner.ClientType).ToString() + ":" + Owner.Account;

                    MultiMimeMessage mmMessage = new MultiMimeMessage(me, me);
                    mmMessage.RoutingHeaders[MIMERoutingHeaders.From][MIMERoutingHeaders.EPID] = NSMessageHandler.MachineGuid.ToString("B").ToLowerInvariant();

                    mmMessage.Stream = 1;
                    mmMessage.ReliabilityHeaders[MIMEReliabilityHeaders.Flags] = "ACK";

                    mmMessage.ContentKey = MIMEContentHeaders.Publication;
                    mmMessage.ContentHeaders[MIMEContentHeaders.URI] = "/user";
                    mmMessage.ContentHeaders[MIMEContentHeaders.ContentType] = "application/user+xml";

                    mmMessage.InnerBody = System.Text.Encoding.UTF8.GetBytes(xml);

                    NSMessage nsMessage = new NSMessage("PUT");
                    nsMessage.InnerMessage = mmMessage;
                    MessageProcessor.SendMessage(nsMessage);
                }
            }
        }
Example #56
0
 public Status(string text, PresenceStatus value, String imageSource)
 {
     this.text = text;
     this.value = value;
     this.imageSource = imageSource;
 }
Example #57
0
        private bool BroadcastingAllowed(PresenceStatus presenceStatus)
        {
            bool broadcastingAllowed = false;

            switch (presenceStatus)
            {
                case PresenceStatus.Online:
                case PresenceStatus.Away:
                case PresenceStatus.BRB:
                case PresenceStatus.Idle:
                case PresenceStatus.Phone:
                case PresenceStatus.Unknown:
                    broadcastingAllowed = true;
                    break;
            }
            return broadcastingAllowed;
        }
Example #58
0
 public abstract void SetPresenceStatus(PresenceStatus status,
                                        string message);
Example #59
0
        protected virtual void OnDisconnected(EventArgs e)
        {
            Trace.Call(e);

            Session.AddTextToChat(
                Chat,
                String.Format(
                    "-!- {0}",
                    String.Format(
                        _("Disconnected from {0}"),
                        NetworkID
                    )
                )
            );

            _PresenceStatus = PresenceStatus.Offline;

            Session.UpdateNetworkStatus();

            if (Disconnected != null) {
                Disconnected(this, e);
            }
        }
Example #60
0
 void UpdatePresenceStatus(PresenceStatus status, string message)
 {
     lock (_ProtocolManagers) {
         foreach (var manager in _ProtocolManagers) {
             manager.SetPresenceStatus(status, message);
         }
     }
 }