Exemple #1
0
        //join

        public void JoinRoom(JID room, string nickname)
        {
            //join room and request no history
            //  <presence to="1660|[email protected]/sureshmsri" xmlns="jabber:client">
            //  <x xmlns="http://jabber.org/protocol/muc">
            //    <history maxchars="0" />
            //  </x>
            //</presence>
            string _to = room + "/" + nickname;

            StringBuilder roomConfig = new StringBuilder();

            roomConfig.Append("<presence to=");
            roomConfig.Append("\"");
            roomConfig.Append(_to);
            roomConfig.Append("\"");
            roomConfig.Append(" xmlns=");
            roomConfig.Append("\"");
            roomConfig.Append("jabber:client");
            roomConfig.Append("\"");
            roomConfig.Append(">");
            roomConfig.Append("<x xmlns=").Append("\"").Append("http://jabber.org/protocol/muc").Append("\"").Append(">");
            roomConfig.Append("<history maxchars=").Append("\"").Append("0").Append("\"").Append("/>").Append("</x>");
            roomConfig.Append("</presence>");
            XMPPClient.SendRawXML(roomConfig.ToString());
        }
Exemple #2
0
 public override bool Equals(object obj)
 {
     if (obj is RosterItem)
     {
         return(JID.Equals(((RosterItem)obj).JID));
     }
     return(false);
 }
Exemple #3
0
        public RosterItem(XMPPClient client, JID jid)
        {
            XMPPClient = client;
            this.JID   = jid;

            /// Set our avatar to our last known avatar
            ///
            this.AvatarImagePath = XMPPClient.AvatarStorage.GetLastHashForJID(this.JID);
        }
Exemple #4
0
 public FileTransfer(string strFileName, int nBytesToBeReceived, JID remotejid, string strSID)
 {
     BytesTotal                 = nBytesToBeReceived;
     BytesRemaining             = nBytesToBeReceived;
     FileName                   = strFileName;
     RemoteJID                  = remotejid;
     this.sid                   = strSID;
     this.FileTransferDirection = com.negociosit.XMPP.XMPPphoton.FileTransferDirection.Receive;
     this.FileTransferState     = com.negociosit.XMPP.XMPPphoton.FileTransferState.WaitingOnUserAccept;
 }
Exemple #5
0
 public FileTransfer(Stream openstream, string strFileName, JID remotejid)
 {
     BytesTotal = (int)openstream.Length;
     FileName   = strFileName;
     //Bytes = bData;
     DataStream = openstream;
     RemoteJID  = remotejid;
     this.FileTransferDirection = com.negociosit.XMPP.XMPPphoton.FileTransferDirection.Send;
     this.FileTransferState     = com.negociosit.XMPP.XMPPphoton.FileTransferState.WaitingOnUserAccept;
 }
Exemple #6
0
 public FileTransfer(byte [] bData, string strFileName, JID remotejid)
 {
     BytesTotal = bData.Length;
     FileName   = strFileName;
     //Bytes = bData;
     DataStream = new MemoryStream(bData);
     RemoteJID  = remotejid;
     this.FileTransferDirection = com.negociosit.XMPP.XMPPphoton.FileTransferDirection.Send;
     this.FileTransferState     = com.negociosit.XMPP.XMPPphoton.FileTransferState.WaitingOnUserAccept;
 }
Exemple #7
0
        public void  RequestVCARD(JID jidfor)
        {
            IQ iq = new IQ();

            iq.From     = XMPPClient.JID;
            iq.To       = jidfor.BareJID;
            iq.Type     = IQType.get.ToString();
            iq.InnerXML = "<vCard xmlns='vcard-temp' />";

            XMPPClient.SendXMPP(iq);
        }
Exemple #8
0
        public void DownloadAvatarJabberIQMethod(JID jidfor)
        {
            IQ iq = new IQ();

            iq.From     = XMPPClient.JID;
            iq.To       = jidfor;
            iq.Type     = IQType.get.ToString();
            iq.InnerXML = "<query xmlns='jabber:iq:avatar' />";
            //iq.InnerXML = "<query xmlns='storage:client:avatar' />";

            XMPPClient.SendXMPP(iq);
        }
Exemple #9
0
        public void UnsubscribeToPresence(JID jidto)
        {
            PresenceMessage pres = new PresenceMessage(null);

            pres.To     = jidto;
            pres.From   = null;
            pres.Type   = "unsubscribe";
            pres.Show   = null;
            pres.Status = null;
            pres.PresenceStatus.PresenceType = PresenceType.unsubscribe;
            XMPPClient.SendObject(pres);
        }
Exemple #10
0
        public RosterItem FindRosterItem(JID jid)
        {
            foreach (RosterItem item in items)
            {
                if (jid.BareJID == item.JID.BareJID)
                {
                    return(item);
                }
            }

            return(null);
        }
Exemple #11
0
 /// <summary>
 /// send delivery receipt
 /// </summary>
 /// <param name="sendToJID"></param>
 /// <param name="toMessageID"></param>
 public void SendChatDeliveryACK(JID sendToJID, string toMessageID)
 {
     try
     {
         string m_strID    = Guid.NewGuid().ToString();
         string ackMessage = "<message from='" + XMPPClient.JID + "' id='" + m_strID + "' to='" + sendToJID + "'> <received xmlns='urn:xmpp:receipts' id='" + toMessageID + "'/> </message>";
         XMPPClient.SendRawXML(ackMessage);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #12
0
        //invite user to join the room
        public void DirectInvite(JID to, JID roomJid)
        {
            try
            {
                //string roomCreation = "<presence to='" + to + "'>" + "<x xmlns='http://jabber.org/protocol/muc'/></presence>";
                string inviteXML = "<message type=\"normal\" to='" + to + "'>" + "<x xmlns='jabber:x:conference' jid='" + roomJid + "'" + " reason='Join this room!'/>" + "</message>";

                XMPPClient.SendRawXML(inviteXML);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #13
0
        public string SendFile(string strFileName, Stream openstream, JID jidto)
        {
            FileTransfer trans = new FileTransfer(openstream, strFileName, jidto)
            {
                FileTransferDirection = FileTransferDirection.Send
            };

            lock (m_objFileTransferLock)
            {
                FileTransfers.Add(trans);
            }

            XMPPClient.StreamInitiationAndTransferLogic.RequestStartFileTransfer(trans);
            return(trans.sid);
        }
Exemple #14
0
 public RosterItemPresenceInstance FindInstance(JID jid)
 {
     RosterItemPresenceInstance[] instances = null;
     lock (m_lockClientInstances)
     {
         foreach (RosterItemPresenceInstance instance in m_listClientInstances)
         {
             if (jid.Equals(instance.FullJID) == true)
             {
                 return(instance);
             }
         }
     }
     return(null);
 }
Exemple #15
0
 //send group chat message
 public void SendGroupChat(JID roomJID, string messagebody)
 {
     try
     {
         ChatMessage msg = new ChatMessage(null);
         msg.From = XMPPClient.JID;
         msg.To   = roomJID;
         msg.Type = "groupchat";
         msg.Body = messagebody;
         XMPPClient.SendXMPP(msg);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #16
0
        public string SendFile(string strFullFileName, byte[] bData, JID jidto)
        {
            string       strFileName = FileTransfer.GetFileNameFromFullString(strFullFileName);
            FileTransfer trans       = new FileTransfer(bData, strFileName, jidto)
            {
                FileTransferDirection = FileTransferDirection.Send
            };

            lock (m_objFileTransferLock)
            {
                FileTransfers.Add(trans);
            }

            XMPPClient.StreamInitiationAndTransferLogic.RequestStartFileTransfer(trans);
            return(trans.sid);
        }
Exemple #17
0
        public IQ SendPing(JID to, bool bWaitForResponse, int nTimeOutMs)
        {
            PingIQ iq = new PingIQ();

            iq.Type = IQType.get.ToString();
            iq.From = XMPPClient.JID.BareJID;
            iq.To   = to;
            if (bWaitForResponse == true)
            {
                return(XMPPClient.SendRecieveIQ(iq, nTimeOutMs, SerializationMethod.XMLSerializeObject));
            }
            else
            {
                XMPPClient.SendObject(iq);
            }
            return(null);
        }
Exemple #18
0
 //set room as persistent
 public IQ SubmitRoomConfiguration(JID roomJid)
 {
     try
     {
         IQ persistentIQ = new IQ();
         persistentIQ.Type     = IQType.set.ToString();
         persistentIQ.From     = XMPPClient.JID;
         persistentIQ.To       = roomJid;
         persistentIQ.ID       = "roomConfigID";
         persistentIQ.InnerXML = "<query xmlns='http://jabber.org/protocol/muc#owner'><x xmlns='jabber:x:data' type='submit'><field type='hidden' var='FORM_TYPE'><value>http://jabber.org/protocol/muc#roomconfig</value></field><field var='muc#roomconfig_persistentroom'><value>true</value></field></x></query>";
         IQ response = XMPPClient.SendRecieveIQ(persistentIQ, 10000);
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void DownloadDataNode(JID jidto, string strNodeName, string strItem)
        {
            PubSubIQ iq = new PubSubIQ();

            iq.Type           = IQType.set.ToString();
            iq.To             = null; /// null for personal eventing pub sub
            iq.From           = XMPPClient.JID;
            iq.PubSub.Publish = new Publish()
            {
                Node = strNodeName, Item = new PubSubItem()
                {
                    Id = strNodeName
                }
            };

            ListSentIQs.Add(iq.ID);
            XMPPClient.SendObject(iq);
        }
Exemple #20
0
        public string SendFile(string strFullFileName, JID jidto)
        {
            string     strFileName = FileTransfer.GetFileNameFromFullString(strFullFileName);
            FileStream DataStream  = new FileStream(strFullFileName, FileMode.Open, FileAccess.Read);

            FileTransfer trans = new FileTransfer(DataStream, strFileName, jidto)
            {
                FileTransferDirection = FileTransferDirection.Send
            };

            lock (m_objFileTransferLock)
            {
                FileTransfers.Add(trans);
            }

            XMPPClient.StreamInitiationAndTransferLogic.RequestStartFileTransfer(trans);
            return(trans.sid);
        }
Exemple #21
0
 //get the room configuration
 public IQ RequestRoomConfiguration(JID roomJID)
 {
     try
     {
         IQ roomConfigiq = new IQ();
         roomConfigiq.Type     = IQType.get.ToString();
         roomConfigiq.From     = XMPPClient.JID;
         roomConfigiq.To       = roomJID;
         roomConfigiq.InnerXML = "<query xmlns='http://jabber.org/protocol/muc#owner'/>";
         roomConfigiq.ID       = "roomConfigID";
         IQ response = XMPPClient.SendRecieveIQ(roomConfigiq, 10000);
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #22
0
 //exit from group
 public IQ DestroyRoom(JID roomJID)
 {
     try
     {
         IQ destroyIQ = new IQ();
         destroyIQ.Type     = IQType.set.ToString();
         destroyIQ.From     = XMPPClient.JID;
         destroyIQ.To       = roomJID;
         destroyIQ.ID       = "modifyRoomListID";
         destroyIQ.InnerXML = "<query xmlns='http://jabber.org/protocol/muc#owner'><destroy jid='" + roomJID + "'><reason>delete</reason></destroy></query>";
         IQ response = XMPPClient.SendRecieveIQ(destroyIQ, 10000);
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #23
0
 //roster Activity
 public IQ RosterLastActivity(JID toJID)
 {
     try
     {
         IQ lastActivity = new IQ();
         lastActivity.Type     = IQType.get.ToString();
         lastActivity.From     = XMPPClient.JID;
         lastActivity.To       = toJID;
         lastActivity.ID       = "TAPlastActivityID";
         lastActivity.InnerXML = "<query xmlns='jabber:iq:last'/>";
         IQ response = XMPPClient.SendRecieveIQ(lastActivity, 10000);
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #24
0
 //rejoin the banned user
 public IQ ModifyRoomList(JID roomJID, JID memberJID)
 {
     try
     {
         IQ modifyList = new IQ();
         modifyList.Type     = IQType.set.ToString();
         modifyList.From     = XMPPClient.JID;
         modifyList.To       = roomJID;
         modifyList.ID       = "modifyRoomListID";
         modifyList.InnerXML = "<query xmlns='http://jabber.org/protocol/muc#admin'><item affiliation='none' jid='" + memberJID + "'><reason>rejoin</reason></item></query>";
         IQ response = XMPPClient.SendRecieveIQ(modifyList, 10000);
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #25
0
 //request banned user list
 public IQ RequestMembersList(JID roomJID)
 {
     try
     {
         IQ memberList = new IQ();
         memberList.Type     = IQType.get.ToString();
         memberList.From     = XMPPClient.JID;
         memberList.To       = roomJID;
         memberList.ID       = "memberlistID";
         memberList.InnerXML = "<query xmlns='http://jabber.org/protocol/muc#admin'><item affiliation='outcast'/></query>";
         IQ response = XMPPClient.SendRecieveIQ(memberList, 10000);
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #26
0
 //remove the user from room
 public IQ BanUser(JID roomJID, JID banUserJID)
 {
     try
     {
         IQ banuserIQ = new IQ();
         banuserIQ.Type     = IQType.set.ToString();
         banuserIQ.From     = XMPPClient.JID;
         banuserIQ.To       = roomJID;
         banuserIQ.ID       = "banUserTAPID";
         banuserIQ.InnerXML = "<query xmlns='http://jabber.org/protocol/muc#admin'><item affiliation='outcast' jid='" + banUserJID + "'/>" + "</query>";
         IQ response = XMPPClient.SendRecieveIQ(banuserIQ, 10000);
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #27
0
        public void JoinRoom(JID room, string nickname, DateTime historySince)
        {
            string        _to         = room + "/" + nickname;
            string        historyFrom = Time.Iso8601DateString(historySince);
            StringBuilder roomConfig  = new StringBuilder();

            roomConfig.Append("<presence to=");
            roomConfig.Append("\"");
            roomConfig.Append(_to);
            roomConfig.Append("\"");
            roomConfig.Append(" xmlns=");
            roomConfig.Append("\"");
            roomConfig.Append("jabber:client");
            roomConfig.Append("\"");
            roomConfig.Append(">");
            roomConfig.Append("<x xmlns=").Append("\"").Append("http://jabber.org/protocol/muc").Append("\"").Append(">");
            roomConfig.Append("<history since=").Append("\"").Append(historyFrom).Append("\"").Append("/>").Append("</x>");
            roomConfig.Append("</presence>");
            XMPPClient.SendRawXML(roomConfig.ToString());
        }
Exemple #28
0
        //join the room
        public void EnterRoom(JID room, string joinerName)
        {
            try
            {
                //         <presence from='[email protected]/balcony'
                //          to='[email protected]/JuliC'>
                //  <x xmlns='http='http://jabber.org/protocol/muc'/>
                //</presence>
                // string roomCreation = "<presence from='"+XMPPClient.JID.BareJID+"/"+" to='" + room + "/" + joinerName + "'>" + "<x xmlns='http://jabber.org/protocol/muc'/> " + "<history maxstanzas='0'/></presence>";

                ////<presence to="1660|[email protected]/sureshmsri" xmlns="jabber:client">
                //<x xmlns="http://jabber.org/protocol/muc" />
//</presence>


                string _to = room + "/" + joinerName;

                StringBuilder roomConfig = new StringBuilder();
                roomConfig.Append("<presence to=");
                roomConfig.Append("\"");
                roomConfig.Append(_to);
                roomConfig.Append("\"");
                roomConfig.Append(" xmlns=");
                roomConfig.Append("\"");
                roomConfig.Append("jabber:client");
                roomConfig.Append("\"");
                roomConfig.Append(">");
                roomConfig.Append("<x xmlns=").Append("\"").Append("http://jabber.org/protocol/muc").Append("\"").Append(">");
                roomConfig.Append("<history maxchars=").Append("\"").Append("0").Append("\"").Append("/>").Append("</x>");
                roomConfig.Append("</presence>");

                //  string roomCreation = "<presence to="+"\" +"_to\""" +  + "<x xmlns='http://jabber.org/protocol/muc'/> " + "<history seconds='0'/></presence>";

                // XMPPClient.SendXMPP(SendIQ);
                XMPPClient.SendRawXML(roomConfig.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public Conversation(JID jid)
 {
     JID = jid;
 }
        public override bool NewMessage(Message iq)
        {
            /// See if this is a standard text message
            ///
            if (iq is ChatMessage)
            {
                ChatMessage chatmsg = iq as ChatMessage;
                RosterItem  item    = XMPPClient.FindRosterItem(chatmsg.From);
                if (item != null)
                {
                    if (chatmsg.Body != null)
                    {
                        TextMessage txtmsg = new TextMessage();
                        txtmsg.From     = chatmsg.From;
                        txtmsg.To       = chatmsg.To;
                        txtmsg.Received = DateTime.Now;
                        if (chatmsg.Delivered.HasValue == true)
                        {
                            txtmsg.Received = chatmsg.Delivered.Value; /// May have been a server stored message
                        }
                        txtmsg.Message = chatmsg.Body;
                        txtmsg         = ExtractThread(txtmsg, true);
                        txtmsg.Sent    = false;
                        item.AddRecvTextMessage(txtmsg);
                        item.HasNewMessages = true;

                        // Notify XMPPClient that a new conversation item has been added
                        XMPPClient.FireNewConversationItem(item, true, txtmsg, iq.ID);
                    }
                    if (chatmsg.ConversationState != ConversationState.none)// A conversation message
                    {
                        item.Conversation.ConversationState = chatmsg.ConversationState;
                        XMPPClient.FireNewConversationState(item, item.Conversation.ConversationState);
                    }
                    else
                    {
                        XDocument xmldocument = XDocument.Parse(iq.InnerXML.ToString());
                        if (xmldocument.Root.LastAttribute != null)
                        {
                            string id = xmldocument.Root.LastAttribute.Value.ToString();
                            XMPPClient.FireDelegateReceiptHandler(chatmsg.From, id);
                        }
                    }
                }
                if (item == null)
                {
                    XDocument xmldocument = XDocument.Parse(iq.InnerXML.ToString());
                    if (xmldocument.Root.LastAttribute != null)
                    {
                        string id = xmldocument.Root.LastAttribute.Value.ToString();
                        XMPPClient.FireDelegateReceiptHandler(chatmsg.From, id);
                    }
                }

                return(true);
            }
            //suresh handle group chat
            else if (iq.Type == "groupchat")
            {
                XDocument xmldoc = XDocument.Parse(iq.InnerXML.ToString());
                string    body   = xmldoc.Descendants("body").Single().Value.ToString();
                XMPPClient.FireNewGroupConversation(iq, body);
            }

            else if (iq.Type == "normal")
            {
                XDocument xmldocument = XDocument.Parse(iq.MessageXML.ToString());
                XMPPClient.FireNewGroupConversation(iq, xmldocument.ToString());
            }
            //suresh handle receipt
            else if (iq.Type == "" || iq.Type == null)
            {
                XDocument xmldocument    = XDocument.Parse(iq.InnerXML.ToString());
                string    id             = xmldocument.Root.LastAttribute.Value.ToString();
                JID       messageFromJID = iq.From;

                XMPPClient.FireDelegateReceiptHandler(messageFromJID, id);
            }
            return(false);
        }