コード例 #1
0
 private static void ErrorPresence(Presence presence, ErrorCondition condition)
 {
     presence.SwitchDirection();
     presence.RemoveAllChildNodes();
     presence.AddChild(new Muc());
     presence.Type  = PresenceType.error;
     presence.Error = new Error(condition);
 }
コード例 #2
0
        public Presence Conflict()
        {
            Presence presence = new Presence()
            {
                Type = PresenceType.error
            };

            presence.AddChild(new Muc());
            presence.Error = new Error(ErrorCondition.Conflict);
            presence.From  = room.Jid;
            return(presence);
        }
コード例 #3
0
ファイル: MucService.cs プロジェクト: jlauinger/miniConf
        /// <summary>
        /// Join a Multi-user room
        /// </summary>
        /// <param name="room">room data object</param>
        /// <param name="loadAllHistory">request all history from server (10000 stanzas max)</param>
        public void joinRoom(Roomdata room, bool loadAllHistory = false)
        {
            //

            Program.db.SetOnlineStatus(room.RoomName, "off");

            /// Setup Room
            agsXMPP.protocol.client.Presence MUCpresence = new Presence();
            //MUCpresence.From = jabber.conn.MyJID;
            MUCpresence.To = room.jid;

            var xMuc = new Muc();

            MUCpresence.AddChild(xMuc);

            //if (glob.para("notifications__" + roomJid.Bare) == "FALSE") xMuc.SetTag("show", "away");
            if (room.Notify != Roomdata.NotifyMode.Always)
            {
                xMuc.SetTag("show", "away");
            }

            agsXMPP.protocol.x.muc.History historyChild = new History(100);
            try {
                string since = room.LastMessageDt; //logs.GetLastmessageDatetime(room.jid.Bare);
                if (!String.IsNullOrEmpty(since))
                {
                    historyChild.RemoveAttribute("maxstanzas");
                    historyChild.SetAttribute("since", since);
                    //addNoticeToView("Requesting since " + since);
                }
            } catch (Exception e) {
            }

            if (loadAllHistory)
            {
                historyChild = new History(10000);
            }

            xMuc.AddChild(historyChild);

            //MUCpresence.SetAttribute("type", "groupchat");

            Console.WriteLine("-> " + MUCpresence.ToString());
            Program.Jabber.conn.Send(MUCpresence);
        }
コード例 #4
0
        public void EnterRoom(params int[] codes)
        {
            PresenceType = PresenceType.available;

            //Create presence and send it back
            Presence backPresence = Presence;

            backPresence.RemoveAllChildNodes();
            User user = User;

            foreach (int code in codes)
            {
                user.AddChild(new Status(code));
            }
            user.AddChild(new Status(110));            //Entered
            backPresence.AddChild(user);
            Send(backPresence);
        }
コード例 #5
0
        public static string FriendStatus(string username)
        {
            NetTalk.BLL.Users           api          = new NetTalk.BLL.Users();
            List <NetTalk.DAL.VwFriend> OnlineFriend = api.ListOnlinFriend(username);

            ShowType     userShowType;
            PresenceType userIsOnline;
            Presence     p;

            string list           = "";
            string userStatusText = "";

            for (int i = 0; i < OnlineFriend.Count; i++)
            {
                userStatusText = OnlineFriend[i].UserStatusText;
                userIsOnline   = PresenceType.available;
                userShowType   = (ShowType)OnlineFriend[i].UserStatus;

                p      = new Presence();
                p.From = new agsXMPP.Jid(OnlineFriend[i].FriendUserName + "@" + Config.AppSetting.domain);
                p.To   = new agsXMPP.Jid(username + "@" + Config.AppSetting.domain);
                p.Type = userIsOnline;
                p.Show = userShowType;
                if (!string.IsNullOrEmpty(userStatusText))
                {
                    p.Status = userStatusText;
                }
                if (!string.IsNullOrEmpty(OnlineFriend[i].VcardPhoto))
                {
                    Element xtag = new Element("x");
                    xtag.Namespace = "vcard-temp:x:update";
                    Element photo = new Element("photo");
                    photo.Value = OnlineFriend[i].VcardPhoto;
                    xtag.AddChild(photo);
                    p.AddChild(xtag);
                }

                list += p.ToString();
            }

            return(list);
        }
コード例 #6
0
        private void DestroyRoom(Destroy destroy)
        {
            Presence offline = new Presence();

            offline.Type = PresenceType.unavailable;
            User user = new User();

            user.Item = new Item(Affiliation.none, Role.none);
            offline.AddChild(user);
            user.AddChild(destroy);
            destroy.Namespace = null;

            foreach (MucRoomMember member in members)
            {
                offline.From = member.Jid;
                member.Send(offline);
            }
            members.Clear();
            mucService.RemoveRoom(this);
        }
コード例 #7
0
        public void TestCaps()
        {
            PresenceManager pp   = new PresenceManager();
            Presence        pres = new Presence(doc);

            pres.From = baz;

            CapsManager cm = new CapsManager();

            pp.CapsManager = cm;

            cm.FileName = "caps.xml";
            cm.Node     = "http://cursive.net/clients/PresenceManagerTest";
            cm.AddFeature(URI.DISCO_INFO);
            cm.AddFeature(URI.DELAY);
            cm.AddIdentity("client", "pc", null, "Presence Manager Test");

            DiscoInfo info = new DiscoInfo(doc);

            cm.FillInInfo(info);
            cm[cm.Ver] = info;

            pres.AddChild(cm.GetCaps(pres.OwnerDocument));
            pp.AddPresence(pres);

            JID dij = pp.GetFeatureJID(bare, URI.DISCO_INFO);

            Assert.AreEqual(baz, dij);
            dij = pp.GetFeatureJID(bare, URI.DISCO_ITEMS);
            Assert.IsNull(dij);
            dij = pp.GetFeatureJID(baz, URI.DISCO_INFO);
            Assert.AreEqual(baz, dij);

            StringSet fs = pp.GetFeatures(bare);

            Assert.IsTrue(fs[URI.DISCO_INFO]);
            Assert.IsFalse(fs[URI.DISCO_ITEMS]);
        }
コード例 #8
0
        public static Presence GetPresence(string username)
        {
            Presence p = new Presence();

            NetTalk.BLL.Users   api  = new NetTalk.BLL.Users();
            NetTalk.DAL.TbUsers user = api.Find(username);

            p.Show   = GetShowType(user.TbUserStatus.UserStatus);
            p.Type   = (user.TbUserStatus.UserIsOnline) ? PresenceType.available : PresenceType.unavailable;
            p.Status = user.TbUserStatus.UserStatusText;

            if (!string.IsNullOrEmpty(user.TbVcard.VcardPhoto))
            {
                Element xtag = new Element("x");
                xtag.Namespace = "vcard-temp:x:update";
                Element photo = new Element("photo");
                photo.Value = user.TbVcard.VcardPhoto;
                xtag.AddChild(photo);
                p.AddChild(xtag);
            }

            return(p);
        }
コード例 #9
0
        public void TestCaps()
        {
            PresenceManager pp = new PresenceManager();
            Presence pres = new Presence(doc);
            pres.From = baz;

            CapsManager cm = new CapsManager();
            pp.CapsManager = cm;

            cm.FileName = "caps.xml";
            cm.Node = "http://cursive.net/clients/PresenceManagerTest";
            cm.AddFeature(URI.DISCO_INFO);
            cm.AddFeature(URI.DELAY);
            cm.AddIdentity("client", "pc", null, "Presence Manager Test");

            DiscoInfo info = new DiscoInfo(doc);
            cm.FillInInfo(info);
            cm[cm.Ver] = info;

            pres.AddChild(cm.GetCaps(pres.OwnerDocument));
            pp.AddPresence(pres);

            JID dij = pp.GetFeatureJID(bare, URI.DISCO_INFO);
            Assert.AreEqual(baz, dij);
            dij = pp.GetFeatureJID(bare, URI.DISCO_ITEMS);
            Assert.IsNull(dij);
            dij = pp.GetFeatureJID(baz, URI.DISCO_INFO);
            Assert.AreEqual(baz, dij);

            StringSet fs = pp.GetFeatures(bare);
            Assert.IsTrue(fs[URI.DISCO_INFO]);
            Assert.IsFalse(fs[URI.DISCO_ITEMS]);
        }
コード例 #10
0
        /// <summary>
        /// Join a chatroom
        /// </summary>
        /// <param name="room">
        /// jid of the room to join
        /// </param>
        /// <param name="nickname">
        /// nickname to use in the room
        /// </param>
        /// <param name="password">
        /// password for password protected chat rooms
        /// </param>
        /// <param name="disableHistory">
        /// true for joining without chat room history
        /// </param>
        public void JoinRoom(Jid room, string nickname, string password, bool disableHistory)
        {
            /*
            <presence
                from='[email protected]/pda'
                to='[email protected]/thirdwitch'>
              <x xmlns='http://jabber.org/protocol/muc'>
                <password>cauldron</password>
              </x>
            </presence>

            join room and request no history
            <presence
                from='[email protected]/pda'
                to='[email protected]/thirdwitch'>
              <x xmlns='http://jabber.org/protocol/muc'>
                <history maxchars='0'/>
              </x>
            </presence>
            */
            Jid to = new Jid(room.ToString());
            to.Resource = nickname;

            Presence pres = new Presence();
            pres.To = to;
            Muc x = new Muc();
            if (password != null)
            {
                x.Password = password;
            }

            if (disableHistory)
            {
                History hist = new History();
                hist.MaxCharacters = 0;
                x.History = hist;
            }

            pres.AddChild(x);

            m_connection.Send(pres);
        }