Esempio n. 1
0
        internal MirandaContactSettings(MirandaDB db, BinaryReader reader, int ofs)
        {
            Guard.NullArgument(db, "db");
            Guard.NullArgument(reader, "reader");
            if (reader.BaseStream == null)
            {
                throw new InvalidOperationException("Trying to load contact settings after Miranda DB has been closed");
            }
            _reader = reader;

            reader.BaseStream.Position = ofs;
            int signature = _reader.ReadInt32();

            if (signature != SIGNATURE_CONTACT_SETTINGS)
            {
                throw new MirandaDatabaseCorruptedException("Database corrupted: invalid contact settings signature");
            }

            _ofsNext = reader.ReadInt32();

            int ofsModuleName = reader.ReadInt32();

            _moduleName = db.GetModuleName(ofsModuleName);

            _cbBlob  = reader.ReadInt32();
            _ofsData = reader.BaseStream.Position;
        }
Esempio n. 2
0
        internal MirandaEvent(MirandaDB db, BinaryReader reader, int ofs)
        {
            reader.BaseStream.Position = ofs;
            int signature = reader.ReadInt32();

            if (signature != SIGNATURE_EVENT)
            {
                throw new MirandaDatabaseCorruptedException("Database corrupted: invalid event signature");
            }

            reader.ReadInt32();  // skip _ofsPrev
            _ofsNext = reader.ReadInt32();

            int ofsModuleName = reader.ReadInt32();

            _moduleName = db.GetModuleName(ofsModuleName);

            int timestamp = reader.ReadInt32();

            _timestamp = new DateTime(1970, 1, 1).AddDays((double )timestamp / (24 * 60 * 60));

            _flags     = reader.ReadInt16();
            _eventType = reader.ReadInt32();
            int cbBlob = reader.ReadInt32();

            if (cbBlob == 0)
            {
                _eventData = "";
            }
            else
            {
                byte[] eventData = reader.ReadBytes(cbBlob);
                int    nullIndex = Array.IndexOf(eventData, (byte)0);
                if (_eventType == 0 && nullIndex < cbBlob - 3)
                {
                    _eventData = Encoding.Unicode.GetString(eventData, nullIndex + 1, cbBlob - nullIndex - 3);
                }
                else
                {
                    _eventData = Encoding.Default.GetString(eventData, 0, cbBlob - 1);
                }
            }
        }