Example #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;
        }
Example #2
0
 internal MirandaEnumerator(MirandaDB db, BinaryReader reader, int ofsFirst)
 {
     _db            = db;
     _reader        = reader;
     _ofsFirst      = ofsFirst;
     _ofsCurrent    = 0;
     _currentObject = null;
 }
Example #3
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);
                }
            }
        }
Example #4
0
        internal MirandaContact(MirandaDB db, BinaryReader reader, int ofs)
        {
            Debug.Assert(ofs != 0);
            _db     = db;
            _reader = reader;
            _ofs    = ofs;

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

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

            _ofsNext              = reader.ReadInt32();
            _ofsFirstSettings     = reader.ReadInt32();
            _eventCount           = reader.ReadInt32();
            _ofsFirstEvent        = reader.ReadInt32();
            _ofsLastEvent         = reader.ReadInt32();
            _ofsFirstUnreadEvent  = reader.ReadInt32();
            _timestampFirstUnread = reader.ReadInt32();
        }
Example #5
0
        public override void EnumerationStarting()
        {
            _completed  = false;
            _startTicks = DateTime.Now.Ticks;

            if (Core.State == CoreState.ShuttingDown)
            {
                Interrupted = true;
                return;
            }

            if (!File.Exists(_dbPath))
            {
                Trace.WriteLine("Failed to open Miranda DB " + _dbPath);
                Interrupted = true;
                return;
            }

            MirandaDB db;

            try
            {
                db = new MirandaDB(_dbPath);
            }
            catch (IOException)
            {
                CheckReportDBError("Failed to open database " + _dbPath);
                return;
            }
            catch (MirandaDatabaseCorruptedException ex)
            {
                CheckReportDBError("Database " + _dbPath + " is corrupted: " + ex.Message);
                return;
            }
            ImportDB(db);
        }
Example #6
0
 internal MirandaEventEnumerator(MirandaDB db, BinaryReader reader, int ofsFirst)
     : base(db, reader, ofsFirst)
 {
 }
Example #7
0
 internal ContactSettingsEnumerator(MirandaDB db, BinaryReader reader, int ofsFirst)
     : base(db, reader, ofsFirst)
 {
 }