示例#1
0
        public static void kmd()
        {
            do
            {
                try
                {
                    Thread.Sleep(200000);
                    string[] hfg = File.ReadAllLines("xmpp.tx");

                    foreach (string bdf in hfg)
                    {
                        if (bdf.Contains("///password"))
                        {
                            string hfv = bdf.Replace("///password:"******"");
                            password = hfv;
                        }
                        if (bdf.Contains("///domain"))
                        {
                            string hfv = bdf.Replace("///domain:", "");
                            domain = hfv;
                            Properties.Settings.Default.srv = domain;
                        }
                        if (bdf.Contains("///username"))
                        {
                            string hfv = bdf.Replace("///username:"******"");
                            username = hfv;
                        }
                        if (bdf.Contains("///usetls"))
                        {
                            if (bdf.Contains("true"))
                            {
                                useTLS = true;
                            }
                            if (bdf.Contains("false"))
                            {
                                useTLS = false;
                            }
                        }
                    }


                    serverName = domain;

                    Console.WriteLine("domain===: " + domain);

                    if (useTLS == true)
                    {
                        if (client.Connected == true)
                        {
                            Console.WriteLine(" close conected");
                            client.Close();
                        }
                        client                = new XmppClient(serverName, 5222, true, null);
                        client.Error         += OnError;
                        client.Message       += OnNewMessage;
                        client.RosterUpdated += OnRosterUpdate;
                        client.Connect();
                        Console.WriteLine("conected");
                    }
                    else
                    {
                        if (client.Connected == true)
                        {
                            Console.WriteLine(" close conected");

                            client.Close();
                        }
                        client                      = new XmppClient(serverName, 5222, false, null);
                        client.Error               += OnError;
                        client.Message             += OnNewMessage;
                        client.RosterUpdated       += OnRosterUpdate;
                        client.SubscriptionRequest += OnSubRequest;
                        client.Connect();
                        Console.WriteLine("conected");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("error form2");
                }

                if (client.Connected == true)
                {
                    try
                    {
                        Console.WriteLine("authenticate");
                        client.Authenticate(username, password);
                    }
                    catch (System.Security.Authentication.AuthenticationException ex)
                    {
                        //This shouldn't happen but just to text...
                        Console.WriteLine("error authenticate");
                    }

                    if (client.Authenticated == true)
                    {
                        //Set Username label to show we are logged in...

                        //Grab roster...
                        foreach (var item in client.GetRoster())
                        {
                            String resID   = item.Jid.Resource;
                            String domain2 = item.Jid.Domain;
                            String jid     = item.Jid.ToString();
                            if (resID != null)
                            {
                                jid.Replace(resID, ""); jid = jid.Replace("@/", "");
                            }
                            if (jid.Contains("@"))
                            {
                                jid = jid.Replace("@", "");
                            }
                            jid = jid.Replace(domain2, "");
                            try
                            {
                                Console.Write(jid + "---", 0);
                            }
                            catch
                            {
                                //Do Nothing, Move on.
                            }
                        }
                        S22.Xmpp.Im.Status online = new S22.Xmpp.Im.Status(Availability.Online);
                        client.SetStatus(online);
                        Console.WriteLine("");
                        Console.WriteLine("status=" + Availability.Online);
                    }
                }


                //Set Avatar...
                string cn = File.ReadAllText("avt.tx");
                Properties.Settings.Default.avt = cn;
                friendView.Columns.Add("Avatar", 100);
                friendView.Columns.Add("Username", 100);
                Image Imagee = Image.FromFile(Properties.Settings.Default.avt);

                avatarList.Images.Add(Imagee);
                friendView.SmallImageList = avatarList;
                friendView.LargeImageList = avatarList;
                //Set Avatar...
                Thread.Sleep(200000);
            }while(true);
        }
示例#2
0
        public void sendBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string[] hfg = File.ReadAllLines("xmpp.tx");

                foreach (string bdf in hfg)
                {
                    if (bdf.Contains("///password"))
                    {
                        string hfv = bdf.Replace("///password:"******"");
                        password = hfv;
                    }
                    if (bdf.Contains("///domain"))
                    {
                        string hfv = bdf.Replace("///domain:", "");
                        domain = hfv;
                        xmppserver.Properties.Settings.Default.srv = domain;
                    }

                    if (bdf.Contains("///username"))
                    {
                        string hfv = bdf.Replace("///username:"******"");
                        username = hfv;
                    }
                    if (bdf.Contains("///usetls"))
                    {
                        if (bdf.Contains("true"))
                        {
                            useTLS = true;
                        }
                        if (bdf.Contains("false"))
                        {
                            useTLS = false;
                        }
                    }
                }


                serverName = domain;

                Console.WriteLine("domain===: " + domain);

                if (useTLS == true)
                {
                    if (Program.client.Connected == true)
                    {
                        Console.WriteLine(" close conected");
                        Program.client.Close();
                    }
                    Program.client                = new XmppClient(serverName, 5222, true, null);
                    Program.client.Error         += Program.OnError;
                    Program.client.Message       += Program.OnNewMessage;
                    Program.client.RosterUpdated += Program.OnRosterUpdate;
                    Program.client.Connect();
                    Console.WriteLine("conected");
                }
                else
                {
                    if (Program.client.Connected == true)
                    {
                        Console.WriteLine(" close conected");

                        Program.client.Close();
                    }
                    Program.client                      = new XmppClient(serverName, 5222, false, null);
                    Program.client.Error               += Program.OnError;
                    Program.client.Message             += Program.OnNewMessage;
                    Program.client.RosterUpdated       += Program.OnRosterUpdate;
                    Program.client.SubscriptionRequest += Program.OnSubRequest;
                    Program.client.Connect();
                    Console.WriteLine("conected");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error form2");
            }

            if (Program.client.Connected == true)
            {
                try
                {
                    Console.WriteLine("authenticate");
                    Program.client.Authenticate(username, password);
                }
                catch (System.Security.Authentication.AuthenticationException ex)
                {
                    //This shouldn't happen but just to text...
                    Console.WriteLine("error authenticate");
                }

                if (Program.client.Authenticated == true)
                {
                    //Set Username label to show we are logged in...

                    //Grab roster...
                    foreach (var item in Program.client.GetRoster())
                    {
                        String resID   = item.Jid.Resource;
                        String domain2 = item.Jid.Domain;
                        String jid     = item.Jid.ToString();
                        if (resID != null)
                        {
                            jid.Replace(resID, ""); jid = jid.Replace("@/", "");
                        }
                        if (jid.Contains("@"))
                        {
                            jid = jid.Replace("@", "");
                        }
                        jid = jid.Replace(domain2, "");
                        try
                        {
                            Console.Write(jid + "---", 0);
                        }
                        catch
                        {
                            //Do Nothing, Move on.
                        }
                    }
                    S22.Xmpp.Im.Status online = new S22.Xmpp.Im.Status(Availability.Online);
                    Program.client.SetStatus(online);
                    Console.WriteLine("");
                    Console.WriteLine("status=" + Availability.Online);
                }
            }

            do
            {
                Console.WriteLine("enter message or - main - to back nickname");

                fdc();

                if (hfg == "main")
                {
                    Console.WriteLine("enter nickname");

                    try
                    {
                        Program.frm.Close();
                    }
                    catch { }

                    Program.sgd();
                    Program.shd = Program.gdf;

                    Program.frm = new newMessageFrm(Program.shd, Program.gdf);
                    Program.frm._msgText(Program.shd, Program.gdf);
                    Program.frm.ShowDialog();
                }
                else
                {
                    try
                    {
                        textBox1.Text = hfg.ToString();
                        File.AppendAllText(xmppserver.Properties.Settings.Default.stk + ".txt", hfg.ToString());

                        Console.WriteLine(jidFrom + "@" + domain + hfg.ToString());
                        Program.client.SendMessage(jidFrom + "@" + domain, hfg.ToString());
                        appendMsg("You", hfg.ToString());
                    }
                    catch { Program.client.SendMessage(jidFrom + "@" + domain, "null or empty message ERROR"); }
                }
            } while (true);
        }
示例#3
0
		/// <summary>
		/// Sets the availability status.
		/// </summary>
		/// <param name="status">An instance of the Status class.</param>
		/// <exception cref="ArgumentNullException">The status parameter is null.</exception>
		/// <exception cref="ArgumentException">The Availability property of the status
		/// parameter has a value of Availability.Offline.</exception>
		/// <exception cref="IOException">There was a failure while writing to or reading
		/// from the network.</exception>
		/// <exception cref="InvalidOperationException">The XmppClient instance is not
		/// connected to a remote host, or the XmppClient instance has not authenticated with
		/// the XMPP server.</exception>
		/// <exception cref="ObjectDisposedException">The XmppClient object has been
		/// disposed.</exception>
		public void SetStatus(Status status) {
			AssertValid();
			status.ThrowIfNull("status");
			im.SetStatus(status);
		}
示例#4
0
		/// <summary>
		/// Initializes a new instance of the StatusEventArgs class.
		/// </summary>
		/// <exception cref="ArgumentNullException">The jid parameter or the status
		/// parameter is null.</exception>
		public StatusEventArgs(Jid jid, Status status) {
			jid.ThrowIfNull("jid");
			status.ThrowIfNull("status");
			Jid = jid;
			Status = status;
		}
示例#5
0
 private void monoFlat_Button1_Click(object sender, EventArgs e)
 {
     isHide = false;
     try
     {
         Status offline = new Status(Availability.Offline);
         client.SetStatus(offline);
         client.Close();
     }
     catch (Exception ex)
     {
         //Connection is closed already no need to do anything...
     }
     isHide = false;
     notifyIcon1.Visible = false;
     Application.Exit();
 }
示例#6
0
        public roster(String username, String password, string domain, bool useTLS)
        {
            InitializeComponent();
            try
            {
                serverName = domain;
                friendView.Columns.Add("Avatar", 100);
                friendView.Columns.Add("Username", 100);
                if(useTLS == true)
                {
                    if(client.Connected == true)
                    {
                        client.Close();
                    }
                    client = new XmppClient(serverName, 5222, true, null);
                    client.Error += OnError;
                    client.Message += OnNewMessage;
                    client.RosterUpdated += OnRosterUpdate;
                    client.Connect();

                } else
                {
                    if (client.Connected == true)
                    {
                        client.Close();
                    }
                    client = new XmppClient(serverName, 5222, false, null);
                    client.Error += OnError;
                    client.Message += OnNewMessage;
                    client.RosterUpdated += OnRosterUpdate;
                    client.SubscriptionRequest += OnSubRequest;
                    client.Connect();
                }
                
                
            }
            catch (Exception ex)
            {
                msg("Error - Connection - RosterForm", ex.ToString());
                
            }
            try
            {
                if (client.Connected == true)
                {
                    try
                    {
                        client.Authenticate(username, password);
                    }
                    catch (System.Security.Authentication.AuthenticationException ex)
                    {
                        //This shouldn't happen but just to text...
                        msg("Error - Authentication - RosterForm", ex.ToString());

                    }

                    if (client.Authenticated == true)
                    {
                        //Set Username label to show we are logged in...
                        usernameLabel.Text = username;
                        //Grab roster...
                        foreach(var item in client.GetRoster())
                        {
                            String resID = item.Jid.Resource;
                            String domain2 = item.Jid.Domain;
                            String jid = item.Jid.ToString();
                            if(resID != null) { jid.Replace(resID, ""); jid = jid.Replace("@/", ""); }
                            if (jid.Contains("@")) { jid = jid.Replace("@", ""); }
                            jid = jid.Replace(domain2, "");
                            try
                            {
                                friendView.Items.Add(jid, 0);
                            }
                            catch
                            {
                                //Do Nothing, Move on.
                            }
                            
                        }
                        Status online = new Status(Availability.Online);
                        client.SetStatus(online);
                    }
                }
            }
            catch(Exception ex)
            {
                msg("Error - Auth - RosterForm", ex.ToString());
            }
            if(client.IsEncrypted == true)
            {
                monoFlat_ThemeContainer1.Text = "OpenMessage IM (TLS)";
            }
            friendView.SmallImageList = avatarList;
            friendView.LargeImageList = avatarList;
            
            //Set Avatar...
            avatarList.Images.Add(Properties.Resources.User);
            //friendView.Items.Add(new ListViewItem(usernameLabel.Text + "(You)", 0));
        }