コード例 #1
0
        /// <summary>
        /// Modify the roles of the parties in this list.
        /// To use, retrive a ParticipantCollection, change the roles
        /// of the parties in that collection, then pass that modified
        /// collection in here.
        /// </summary>
        /// <param name="parties">The modified participant collection</param>
        /// <param name="reason">The reason for the change</param>
        /// <param name="callback">A callback to call when complete.  Will have a null IQ if there were no changes to make.</param>
        /// <param name="state">Caller's state information</param>
        public void ModifyRoles(ParticipantCollection parties, string reason, IqCB callback, object state)
        {
/*
<iq from='[email protected]/globe'
    id='voice4'
    to='*****@*****.**'
    type='set'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item nick='Hecate'
          role='visitor'/>
    <item nick='rosencrantz'
          role='participant'>
      <reason>A worthy fellow.</reason>
    </item>
    <item nick='guildenstern'
          role='participant'>
      <reason>A worthy fellow.</reason>
    </item>
  </query>
</iq>
*/
            RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document);
            iq.To = m_room;
            iq.Type = IQType.set;
            AdminQuery query = iq.Instruction;

            int count = 0;
            foreach (RoomParticipant party in parties)
            {
                if (party.Changed)
                {
                    count++;
                    AdminItem item = query.AddItem();
                    item.Nick = party.Nick;
                    item.Role = party.Role;
                    item.Reason = reason;
                }
            }
            if (count > 0)
                m_manager.BeginIQ(iq, callback, state);
            else
                callback(this, null, state);
        }
コード例 #2
0
        /// <summary>
        /// Modify the roles of the parties in this list.
        /// To use, retrive a ParticipantCollection, change the roles
        /// of the parties in that collection, then pass that modified
        /// collection in here.
        /// </summary>
        /// <param name="parties">The modified participant collection</param>
        /// <param name="reason">The reason for the change</param>
        /// <param name="callback">A callback to call when complete.  Will have a null IQ if there were no changes to make.</param>
        /// <param name="state">Caller's state information</param>
        public void ModifyAffiliations(ParticipantCollection parties, string reason, IqCB callback, object state)
        {
/*
<iq from='*****@*****.**'
    id='ban2'
    to='[email protected]/throne'
    type='result'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='outcast'
          jid='*****@*****.**'>
      <reason>Treason</reason>
    </item>
  </query>
</iq>
*/
            RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document);
            iq.To = m_room;
            iq.Type = IQType.set;
            AdminQuery query = iq.Instruction;

            int count = 0;
            foreach (RoomParticipant party in parties)
            {
                if (party.Changed && (party.RealJID != null))
                {
                    count++;
                    AdminItem item = query.AddItem();
                    item.JID = party.RealJID;
                    item.Affiliation = party.Affiliation;
                    item.Reason = reason;
                }
            }
            if (count > 0)
                m_manager.BeginIQ(iq, callback, state);
            else
                callback(this, null, state);
        }
コード例 #3
0
        private void GotList(object sender, IQ iq, object state)
        {
            RetrieveParticipantsState rps = (RetrieveParticipantsState)state;
            if (iq.Type == IQType.error)
            {
                rps.Callback(this, null, rps.State);
                return;
            }
/*
<iq from='*****@*****.**'
    id='ban2'
    to='[email protected]/throne'
    type='result'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='outcast'
          jid='*****@*****.**'>
      <reason>Treason</reason>
    </item>
  </query>
</iq>
*/
            ParticipantCollection parties = new ParticipantCollection();
            AdminQuery query = (AdminQuery)iq.Query;
            ParticipantCollection.Modification mod;
            foreach (AdminItem item in query.GetItems())
            {
                Presence pres = new Presence(m_manager.Stream.Document);
                pres.From = new JID(m_jid.User, m_jid.Server, item.Nick);
                UserX x = new UserX(m_manager.Stream.Document);
                RoomItem xi = x.RoomItem;
                xi.Role = item.Role;
                xi.Affiliation = item.Affiliation;
                xi.Nick = item.Nick;
                xi.JID = item.JID;
                pres.AppendChild(x);
                parties.Modify(pres, out mod);
            }
            rps.Callback(this, parties, rps.State);
        }