private void monoFlat_Button1_Click(object sender, EventArgs e)
        {
            String server = Properties.Settings.Default.srv;
            String username = friendName.Text;
            S22.Xmpp.Jid tempName = new S22.Xmpp.Jid(username + "@" + server);
            try
            {
                roster.client.AddContact(tempName);
            }catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            
            this.Close();

        }
Exemple #2
0
        /// <summary>
        /// Writes the conversation into a text filer created in the folder set in parameters.
        /// Constructs the conversation to allow identification of the speaker.
        /// </summary>
        /// <param name="messages">The messages exchanged.</param>
        /// <param name="Note">The note given by the teacher.</param>
        /// <param name="jid">The jid of the student .</param>
        /// <param name="contactName">The name of the student.</param>
        public static void WriteConversation(List <Message> messages, string Note, S22.Xmpp.Jid jid, string contactName)
        {
            List <string> text = new List <string>();

            text.Add("Note : " + Note + "\r");

            // Determine who spoke first
            bool isTeacherLastSpeaker = false;

            if (messages[0].From != jid)
            {
                isTeacherLastSpeaker = false;
            }

            // Add the name of the speaker once for every messages in a row
            foreach (var mess in messages)
            {
                if (mess.From.GetBareJid() == jid.GetBareJid())
                {
                    if (isTeacherLastSpeaker)
                    {
                        text.Add("\r\n " + contactName + " : ");
                        isTeacherLastSpeaker = false;
                    }
                }
                else if (!isTeacherLastSpeaker)
                {
                    text.Add("\r\n Vous : ");
                    isTeacherLastSpeaker = true;
                }

                text.Add(mess.Body);
            }

            // Uses an instance of StreamWriter to insert the lines in a .txt
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(

                       Properties.Settings.Default.FolderRecord + "/" +
                       contactName + "_" +
                       DateTime.Now.ToString("yyyyMMddmm") + ".txt"))
            {
                foreach (string line in text)
                {
                    file.WriteLine(line);
                }
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            using (var client = new XmppClient("jabber.dk", "castoriadis", "georgina"))
            {
                var q = new Queue<string>();
                var ev = new AutoResetEvent(false);
                client.Message += new EventHandler<S22.Xmpp.Im.MessageEventArgs>((o,e) => {
                    lock(q) {
                        q.Enqueue(e.Message.Body);
                    }
                    ev.Set();
                });
                client.Connect();
                var admin = new S22.Xmpp.Jid("*****@*****.**");
                client.SendMessage(admin, "You're granted access to Castoriadis!");

                Console.MainClass._readCommand = () =>
                {
                    ev.WaitOne();
                    lock (q)
                    {
                        return q.Dequeue();
                    }
                };
                Console.MainClass._writeResult = s =>
                {
                    var msg = s == null ? "(null)" : s.ToString();
                    if (string.IsNullOrWhiteSpace(msg))
                    {
                        msg = "(empty string)";
                    }
                    client.SendMessage(admin, msg);
                };
                Console.MainClass.Main(args);
            }
        }
Exemple #4
0
 private bool Check(S22.Xmpp.Jid jid)
 {
     return(true);
 }