Beispiel #1
0
        public void leaveRoom(Roomdata room)
        {
            Program.db.SetOnlineStatus(room.RoomName, "off");
            room.online = false;

            Presence MUCpresence = new Presence();

            //MUCpresence.From = jabber.conn.MyJID;
            MUCpresence.To   = room.jid;
            MUCpresence.Type = PresenceType.unavailable;
            Program.Jabber.conn.Send(MUCpresence);
        }
Beispiel #2
0
        public static Roomdata FromDbDataRecord(DbDataRecord record)
        {
            Roomdata r = new Roomdata(record.GetString(COL_ROOM));

            r.LastMessageDt   = SqlDatabase.StringOrNull(record, COL_LASTMESSAGEDT);
            r.Subject         = SqlDatabase.StringOrNull(record, COL_SUBJECT);
            r.DoJoin          = (JoinMode)record.GetInt32(COL_DO_JOIN);
            r.DisplayName     = SqlDatabase.StringOrNull(record, COL_DISPLAY_NAME);
            r.LastSeenDt      = SqlDatabase.StringOrNull(record, COL_LASTSEENDT);
            r.Notify          = (NotifyMode)record.GetInt32(COL_NOTIFY);
            r.DisplayPosition = record.GetInt32(COL_DISPLAY_POSITION);
            return(r);
        }
Beispiel #3
0
        public List <Roomdata> GetRooms(bool joinOnly)
        {
            var cmd = dataBase.CreateCommand();

            cmd.CommandText = "SELECT * FROM room " + (joinOnly ? " WHERE join = 1" : "") + " ORDER BY display_position ; ";
            var             reader = cmd.ExecuteReader();
            List <Roomdata> list   = new List <Roomdata>();

            foreach (DbDataRecord rec in reader)
            {
                list.Add(Roomdata.FromDbDataRecord(rec));
            }
            return(list);
        }
Beispiel #4
0
        /*
         * public void SetLastmessageDatetime(string room, string lastmessage_dt) {
         *  this.ExecSQL("INSERT OR IGNORE INTO room VALUES (?, ?, '', '', '', '', '', '') ", room, lastmessage_dt);
         *  this.ExecSQL("UPDATE room SET lastmessagedt = ? WHERE room = ? ", lastmessage_dt, room);
         * }
         * public void SetSubject(string room, string subject) {
         *  this.ExecSQL("INSERT OR IGNORE INTO room VALUES (?, '', '', '', '', '', '', '') ", room);
         *  this.ExecSQL("UPDATE room SET subject = ? WHERE room = ? ", subject, room);
         * }*/
        public int StoreRoom(Roomdata room)
        {
            var cmd = dataBase.CreateCommand();

            cmd.CommandText = "INSERT OR REPLACE INTO room VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7)";
            cmd.Parameters.Add(new SQLiteParameter("@p" + Roomdata.COL_SUBJECT, String.IsNullOrEmpty(room.Subject) ? "" : room.Subject));
            cmd.Parameters.Add(new SQLiteParameter("@p" + Roomdata.COL_ROOM, room.jid.Bare));
            cmd.Parameters.Add(new SQLiteParameter("@p" + Roomdata.COL_NOTIFY, (int)room.Notify));
            cmd.Parameters.Add(new SQLiteParameter("@p" + Roomdata.COL_DO_JOIN, (int)room.DoJoin));
            cmd.Parameters.Add(new SQLiteParameter("@p" + Roomdata.COL_DISPLAY_POSITION, (int)room.DisplayPosition));
            cmd.Parameters.Add(new SQLiteParameter("@p" + Roomdata.COL_LASTMESSAGEDT, room.LastMessageDt));
            cmd.Parameters.Add(new SQLiteParameter("@p" + Roomdata.COL_LASTSEENDT, room.LastSeenDt));
            cmd.Parameters.Add(new SQLiteParameter("@p" + Roomdata.COL_DISPLAY_NAME, room.DisplayName));
            return(cmd.ExecuteNonQuery());
        }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
        //OTR.Interface.OTRSessionManager otr_ses;

        public DirectMessageForm(Jid jid) : this()
        {
            this.otherEnd = jid;
            this.room     = new Roomdata(jid);
            this.Text     = jid;
        }