Ejemplo n.º 1
0
        private void OnSubscribePresence(Presence presence)
        {
            Contact contact;

            lock (_realContacts)
            {
                contact = FindContact(presence.From);
            }

            switch (presence.Type)
            {
                case PresenceType.subscribe:
                    {
                        VcardIq viq = new VcardIq(IqType.get, presence.From);
                        Account.Instance.XmppConnection.IqGrabber.SendIq(viq, new IqCB(VcardResultAuth),
                                                                         (contact ?? (object) presence));

                        if (contact == null)
                        {
                            Authorization.Instance.Ask(presence);
                        }
                        else
                        {
                            Authorization.Instance.Ask(contact);
                        }
                        break;
                    }
                case PresenceType.subscribed:
                    {
                        if (contact == null)
                        {
                            EventInfo eventinfo =
                                new EventInfo(string.Format("'{0}' just authorized you", presence.From));
                            Events.Instance.OnEvent(this, eventinfo);
                        }
                        else
                        {
                            EventInfo eventinfo =
                                new EventInfo(
                                    string.Format("'{0} ({1})' just authorized you", contact.DisplayName, contact.Jid));
                            Events.Instance.OnEvent(this, eventinfo);

                            // try to get v-card instantly
                            VcardIq viq = new VcardIq(IqType.get, contact.Jid);
                            Account.Instance.XmppConnection.IqGrabber.SendIq(viq, new IqCB(VcardResult), contact);
                        }

                        break;
                    }
                case PresenceType.unsubscribe:
                    {
                        break;
                    }
                case PresenceType.unsubscribed:
                    {
                        if (contact == null)
                        {
                            EventInfo eventinfo =
                                new EventInfo(string.Format("'{0}' removed your authorization", presence.From));
                            Events.Instance.OnEvent(this, eventinfo);
                        }
                        else
                        {
                            EventInfo eventinfo =
                                new EventInfo(
                                    string.Format("'{0} ({1})' removed your authorization", contact.DisplayName,
                                                  contact.Jid));
                            Events.Instance.OnEvent(this, eventinfo);
                        }

                        break;
                    }
            }
        }
Ejemplo n.º 2
0
        public void RequestAuthorization(IContact contact)
        {
            Account.Instance.GetPresenceManager().Subcribe(contact.Jid);

            EventInfo eventinfo =
                new EventInfo(
                    string.Format("You've asked '{0} ({1})' for authorization", contact.DisplayName, contact.Jid));
            Events.Instance.OnEvent(this, eventinfo);
        }
Ejemplo n.º 3
0
        public void ApproveAuthorization(IContact contact)
        {
            Account.Instance.GetPresenceManager().ApproveSubscriptionRequest(contact.Jid);

            EventInfo eventinfo =
                new EventInfo(string.Format("'{0} ({1})' is now authorized", contact.DisplayName, contact.Jid));
            Events.Instance.OnEvent(this, eventinfo);
        }
Ejemplo n.º 4
0
        public void AuthorizeContact(IContact contact, bool approve)
        {
            if (approve)
            {
                ApproveAuthorization(contact);
            }
            else
            {
                Account.Instance.GetPresenceManager().RefuseSubscriptionRequest(contact.Jid);

                EventInfo eventinfo =
                    new EventInfo(string.Format("'{0} ({1})' - authorization denied", contact.DisplayName, contact.Jid));
                Events.Instance.OnEvent(this, eventinfo);
            }
        }
        protected void DisplayQuestionaireInternal(Command command, Service service)
        {
            ServiceCommandExecution serviceCommandExecution = new ServiceCommandExecution(command, service);

            CommandExecute commandExecuteWindow;

            try
            {
                commandExecuteWindow = new CommandExecute(serviceCommandExecution);
                commandExecuteWindow.Show();
            }

            catch (WindowExistsException e)
            {
                commandExecuteWindow = (CommandExecute)e.Control;
                commandExecuteWindow.Redisplay(serviceCommandExecution);
            }

            if (command.Status == Status.canceled)
            {
                EventInfo eventinfo = new EventInfo(string.Format(Resources.Event_CommandCancelled, service.Name));
                Events.Instance.OnEvent(this, eventinfo);

                commandExecuteWindow.Close();
            }
        }