Ejemplo n.º 1
0
        public FrmGroupChat(XmppClient xmppClient, Jid roomJid, string nickname, ListView listContract)
        {
            InitializeComponent();
            local_history = new HistoryTransactionTableAdapter();
            connection    = new SqlCeConnection(local_history.Connection.ConnectionString);
            _roomJid      = roomJid;
            _xmppClient   = xmppClient;
            _nickname     = nickname;
            _listContract = listContract;
            fm.XmppClient = FrmLogin.Instance.xmppClient;
            fm.OnFile    += fm_OnFile;
            Text          = roomJid.User + " Group";;
            mm            = new MucManager(xmppClient);

            // Setup new Message Callback using the MessageFilter
            _xmppClient.MessageFilter.Add(roomJid, new BareJidComparer(), MessageCallback);

            // Setup new Presence Callback using the PresenceFilter
            _xmppClient.PresenceFilter.Add(roomJid, new BareJidComparer(), PresenceCallback);

            GetLastRow(_xmppClient.Username, _xmppClient.XmppDomain, _roomJid.Bare, out LastDtDB);
            btnHistory.Enabled = false;
            Form.CheckForIllegalCrossThreadCalls = false;
            Instance = this;
        }
Ejemplo n.º 2
0
        public FrmGroupChat(XmppClient xmppClient, Jid roomJid, string nickname, ListView listContract)
        {
            InitializeComponent();
            local_history = new HistoryTransactionTableAdapter();
            connection = new SqlCeConnection(local_history.Connection.ConnectionString);
            _roomJid = roomJid;
            _xmppClient = xmppClient;
            _nickname = nickname;
            _listContract = listContract;
            fm.XmppClient = FrmLogin.Instance.xmppClient;
            fm.OnFile += fm_OnFile;
            Text = roomJid.User + " Group"; ;
            mm = new MucManager(xmppClient);

            // Setup new Message Callback using the MessageFilter
            _xmppClient.MessageFilter.Add(roomJid, new BareJidComparer(), MessageCallback);

            // Setup new Presence Callback using the PresenceFilter
            _xmppClient.PresenceFilter.Add(roomJid, new BareJidComparer(), PresenceCallback);

            GetLastRow(_xmppClient.Username, _xmppClient.XmppDomain, _roomJid.Bare, out LastDtDB);
            btnHistory.Enabled = false;
            Form.CheckForIllegalCrossThreadCalls = false;
            Instance = this;
        }
Ejemplo n.º 3
0
        private void InitGroupList()
        {
            DataTable dt = new DataTable();
            HistoryTransactionTableAdapter local_history = new HistoryTransactionTableAdapter();
            SqlCeConnection connection = new SqlCeConnection(local_history.Connection.ConnectionString);

            connection.Open();
            SqlCeDataAdapter adapter = new SqlCeDataAdapter(string.Format(@"Select GroupName from HistoryTransaction 
                                            where AccountName = '{0}' and ServerID = '{1}' and IsGroup = '{2}' Group By GroupName",
                                                                          xmppClient.Username, xmppClient.XmppDomain, "1"), connection);

            adapter.Fill(dt);
            connection.Close();
            foreach (DataRow item in dt.Rows)
            {
                if (item[0].ToString() != string.Empty)
                {
                    Jid room    = new Jid(item[0].ToString());
                    var newItem = new RosterListViewItem(room.User ?? room.Bare, 0, null)
                    {
                        Name = room.Bare
                    };
                    listBookmarkedRooms.Items.Add(newItem);
                }
            }

            DiscoManager _dm = new DiscoManager(xmppClient);

            _dm.DiscoverItems("conference." + FrmLogin.Instance.HostName, new EventHandler <IqEventArgs>(DiscoItemsResult));
        }
Ejemplo n.º 4
0
        private void resetDatabaseToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            string query = "DELETE FROM HistoryTransaction";
            HistoryTransactionTableAdapter local_history = new HistoryTransactionTableAdapter();
            SqlCeConnection connection = new SqlCeConnection(local_history.Connection.ConnectionString);

            connection.Open();
            var command = connection.CreateCommand();

            command.CommandText = query;
            command.ExecuteNonQuery();
            connection.Close();
        }
Ejemplo n.º 5
0
        private void FrmHistoryTransaction_Load(object sender, System.EventArgs e)
        {
            DataTable dt = new DataTable();
            HistoryTransactionTableAdapter local_history = new HistoryTransactionTableAdapter();
            SqlCeConnection connection = new SqlCeConnection(local_history.Connection.ConnectionString);

            connection.Open();
            SqlCeDataAdapter adapter = new SqlCeDataAdapter(string.Format(@"Select  Body, DateTime, PIC from HistoryTransaction 
                                            where AccountName = '{0}' and ServerID = '{1}' and GroupName = '{2}' and IsGroup = '{3}' ORDER BY DateTime ASC",
                                                                          _xmppClient.Username, _xmppClient.XmppDomain, _roomJid.Bare, (_isGroup ? "1" : "0")), connection);

            adapter.Fill(dt);
            connection.Close();
            DateTime dtTemp = new DateTime();

            foreach (DataRow item in dt.Rows)
            {
                DateTime dTime   = DateTime.Parse(item["DateTime"].ToString());
                string   decrypt = item["PIC"].ToString() + " said: " + Cryptography.RSA2.Decrypt(item["Body"].ToString());
                if (dt.Rows.IndexOf(item) == 0)
                {
                    dtTemp = dTime;
                    txtBox.SelectionColor     = Color.Black;
                    txtBox.SelectionAlignment = HorizontalAlignment.Center;
                    txtBox.SelectionFont      = new System.Drawing.Font(txtBox.Font, FontStyle.Bold);
                    txtBox.AppendText(dtTemp.ToLongDateString().ToString());
                    txtBox.AppendText("\r\n");
                }
                else if (dtTemp.Date.CompareTo(dTime.Date) != 0)
                {
                    dtTemp = dTime;
                    txtBox.SelectionColor     = Color.Black;
                    txtBox.SelectionAlignment = HorizontalAlignment.Center;
                    txtBox.SelectionFont      = new System.Drawing.Font(txtBox.Font, FontStyle.Bold);
                    txtBox.AppendText(dtTemp.ToLongDateString().ToString());
                    txtBox.AppendText("\r\n");
                }

                txtBox.SelectionAlignment = HorizontalAlignment.Left;
                txtBox.SelectionFont      = new System.Drawing.Font(txtBox.Font, FontStyle.Regular);
                txtBox.AppendText("(" + DateTime.Parse(item["DateTime"].ToString()).TimeOfDay.ToString() + ") " + decrypt);
                txtBox.AppendText("\r\n");
            }
        }
Ejemplo n.º 6
0
        private void FrmHistoryTransaction_Load(object sender, System.EventArgs e)
        {
            DataTable dt = new DataTable();
            HistoryTransactionTableAdapter local_history = new HistoryTransactionTableAdapter();
            SqlCeConnection connection = new SqlCeConnection(local_history.Connection.ConnectionString);
            connection.Open();
            SqlCeDataAdapter adapter = new SqlCeDataAdapter(string.Format(@"Select  Body, DateTime, PIC from HistoryTransaction
                                            where AccountName = '{0}' and ServerID = '{1}' and GroupName = '{2}' and IsGroup = '{3}' ORDER BY DateTime ASC",
                                            _xmppClient.Username, _xmppClient.XmppDomain, _roomJid.Bare, (_isGroup ? "1" : "0")), connection);
            adapter.Fill(dt);
            connection.Close();
            DateTime dtTemp = new DateTime();
            foreach (DataRow item in dt.Rows)
            {
                DateTime dTime = DateTime.Parse(item["DateTime"].ToString());
                string decrypt = item["PIC"].ToString() + " said: " + Cryptography.RSA2.Decrypt(item["Body"].ToString());
                if (dt.Rows.IndexOf(item) == 0)
                {
                    dtTemp = dTime;
                    txtBox.SelectionColor = Color.Black;
                    txtBox.SelectionAlignment = HorizontalAlignment.Center;
                    txtBox.SelectionFont = new System.Drawing.Font(txtBox.Font, FontStyle.Bold);
                    txtBox.AppendText(dtTemp.ToLongDateString().ToString());
                    txtBox.AppendText("\r\n");
                }
                else if (dtTemp.Date.CompareTo(dTime.Date) != 0)
                {
                    dtTemp = dTime;
                    txtBox.SelectionColor = Color.Black;
                    txtBox.SelectionAlignment = HorizontalAlignment.Center;
                    txtBox.SelectionFont = new System.Drawing.Font(txtBox.Font, FontStyle.Bold);
                    txtBox.AppendText(dtTemp.ToLongDateString().ToString());
                    txtBox.AppendText("\r\n");
                }

                txtBox.SelectionAlignment = HorizontalAlignment.Left;
                txtBox.SelectionFont = new System.Drawing.Font(txtBox.Font, FontStyle.Regular);
                txtBox.AppendText("(" + DateTime.Parse(item["DateTime"].ToString()).TimeOfDay.ToString() + ") " + decrypt);
                txtBox.AppendText("\r\n");
            }
        }
Ejemplo n.º 7
0
        public FrmChat(Jid jid, XmppClient con, string nickname)
        {
            _jid          = jid;
            _xmppClient   = con;
            _nickname     = nickname;
            local_history = new HistoryTransactionTableAdapter();
            connection    = new SqlCeConnection(local_history.Connection.ConnectionString);
            InitializeComponent();

            Text = "Chat with " + nickname;

            Util.ChatForms.Add(_jid.Bare.ToLower(), this);
            // Setup new Message Callback
            con.MessageFilter.Add(jid, new BareJidComparer(), OnMessage);

            GetLastRow(_xmppClient.Username, _xmppClient.XmppDomain, _jid.Bare, out LastDtDB);

            this.Load += new EventHandler(FrmChat_Load);
            Instance   = this;
            Form.CheckForIllegalCrossThreadCalls = false;
        }
Ejemplo n.º 8
0
        public FrmChat(Jid jid, XmppClient con, string nickname)
        {
            _jid = jid;
            _xmppClient = con;
            _nickname = nickname;
            local_history = new HistoryTransactionTableAdapter();
            connection = new SqlCeConnection(local_history.Connection.ConnectionString);
            InitializeComponent();

            Text = "Chat with " + nickname;

            Util.ChatForms.Add(_jid.Bare.ToLower(), this);
            // Setup new Message Callback
            con.MessageFilter.Add(jid, new BareJidComparer(), OnMessage);

            GetLastRow(_xmppClient.Username, _xmppClient.XmppDomain, _jid.Bare, out LastDtDB);

            this.Load += new EventHandler(FrmChat_Load);
            Instance = this;
            Form.CheckForIllegalCrossThreadCalls = false;
        }
Ejemplo n.º 9
0
        void FrmHistoryChat_Load(object sender, System.EventArgs e)
        {
            FrmParent.Instance.ShowLoading();
            DataTable dt  = new DataTable();
            DataTable dt1 = new DataTable();
            HistoryTransactionTableAdapter local_history = new HistoryTransactionTableAdapter();
            SqlCeConnection connection = new SqlCeConnection(local_history.Connection.ConnectionString);

            connection.Open();
            SqlCeDataAdapter adapter = new SqlCeDataAdapter(string.Format(@"Select DateTime, convert(nvarchar(12), DateTime, 101) as Date,  
                                            convert(nvarchar(12), DateTime, 108) as Time, PIC,  Body from HistoryTransaction 
                                            where AccountName = '{0}' and ServerID = '{1}' and GroupName = '{2}' and IsGroup = '{3}' ORDER BY DateTime ASC",
                                                                          _xmppClient.Username, _xmppClient.XmppDomain, _roomJid.Bare, (_isGroup ? "1" : "0")), connection);

            adapter.Fill(dt);

            adapter = new SqlCeDataAdapter(string.Format(@"Select Distinct convert(nvarchar(12), DateTime, 101) as Date from HistoryTransaction 
                                            where AccountName = '{0}' and ServerID = '{1}' and GroupName = '{2}' and IsGroup = '{3}'",
                                                         _xmppClient.Username, _xmppClient.XmppDomain, _roomJid.Bare, (_isGroup ? "1" : "0")), connection);
            adapter.Fill(dt1);
            connection.Close();

            foreach (DataRow item in dt.Rows)
            {
                item["Body"] = Cryptography.RSA2.Decrypt(item["Body"].ToString());
            }

            DataSet dataSet = new DataSet();

            dataSet.Tables.Add(dt1);
            dataSet.Tables.Add(dt);
            dataSet.Relations.Add("Content", dataSet.Tables[0].Columns["Date"],
                                  dataSet.Tables[1].Columns["Date"]);
            this.dgcHistoryChat.DataSource = dt1;
            FrmParent.Instance.HideLoading();
        }
Ejemplo n.º 10
0
 private void resetDatabaseToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     string query = "DELETE FROM HistoryTransaction";
     HistoryTransactionTableAdapter local_history = new HistoryTransactionTableAdapter();
     SqlCeConnection connection = new SqlCeConnection(local_history.Connection.ConnectionString);
     connection.Open();
     var command = connection.CreateCommand();
     command.CommandText = query;
     command.ExecuteNonQuery();
     connection.Close();
 }
Ejemplo n.º 11
0
        private void InitGroupList()
        {
            DataTable dt = new DataTable();
            HistoryTransactionTableAdapter local_history = new HistoryTransactionTableAdapter();
            SqlCeConnection connection = new SqlCeConnection(local_history.Connection.ConnectionString);
            connection.Open();
            SqlCeDataAdapter adapter = new SqlCeDataAdapter(string.Format(@"Select GroupName from HistoryTransaction
                                            where AccountName = '{0}' and ServerID = '{1}' and IsGroup = '{2}' Group By GroupName",
                                            xmppClient.Username, xmppClient.XmppDomain, "1"), connection);
            adapter.Fill(dt);
            connection.Close();
            foreach (DataRow item in dt.Rows)
            {
                if (item[0].ToString() != string.Empty)
                {
                    Jid room = new Jid(item[0].ToString());
                    var newItem = new RosterListViewItem(room.User ?? room.Bare, 0, null) { Name = room.Bare };
                    listBookmarkedRooms.Items.Add(newItem);
                }
            }

            DiscoManager _dm = new DiscoManager(xmppClient);
            _dm.DiscoverItems("conference." + FrmLogin.Instance.HostName, new EventHandler<IqEventArgs>(DiscoItemsResult));
        }