Ignore:
Timestamp:
07/29/06 00:53:01 (18 years ago)
Author:
Nicholas Riley
Message:

Better alarm debug description, datastore debugging; use absolute fire time for snoozed alarms too; replace the buggy alarm stack and misaligned sleep message with a painfully constructed alert.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hiptop/pester/net/sabi/pester/Alarms.java

    r295 r296  
    3030    }
    3131
     32    private void dumpAlarms() { // XXX enable via IPC, make validity checking
     33        int i;
     34        DEBUG.p("== ALARMS ==");
     35        for (i = 0 ; i < size() ; ++i) {
     36            DEBUG.p(((Alarm)getItem(i)).description());
     37        }
     38
     39    }
     40    private void dumpDatastore() {
     41        int i;
     42        DEBUG.p("== DATASTORE CONTENTS ==");
     43        byte[][] alarmsData = mDataStore.getRecords();
     44        for (i = 0 ; i < alarmsData.length ; ++i) {
     45            Alarm alarm = new Alarm();
     46            alarm.fromByteArray(alarmsData[i]);
     47            alarm.setUID(mDataStore.getRecordUID(i));
     48            DEBUG.p(alarm.description());
     49        }
     50    }
    3251    void refreshFromDataStore(boolean datastoreRestored) {
    3352        sAlarmList = null;
    34         removeAllItems();
     53        if (datastoreRestored) {
     54            DEBUG.p("+++ BEFORE RESOLUTION +++");
     55            dumpAlarms();
     56            dumpDatastore();
     57        }
     58        removeAllItems(); // XXX no, we can't do this because some alarms may be (a) in the process of being edited, (b) sitting at expiry, or (c) are periodic or snoozed and need their absolute time preserved.  Instead, we should just add all the new records - but what about conflicts?
    3559        if (datastoreRestored)
    36             mDataStore.doneResolvingConflict(); // resolves UID conflicts
     60            mDataStore.doneResolvingConflict(); // renumbers on-device records
     61        if (datastoreRestored) {
     62            DEBUG.p("+++ AFTER RESOLUTION +++");
     63            dumpDatastore();
     64        }
    3765        byte[][] alarmsData = mDataStore.getRecords();
    3866        int i;
     
    4977            MessageFinder.setDefaultMessageList();
    5078        }
     79        DEBUG.p("+++ AFTER RESTORATION +++");
     80        dumpAlarms();
     81        dumpDatastore();
    5182        sAlarmList = this;
    5283    }
     
    80111            return;
    81112        Alarm alarm = (Alarm)item;
    82         DEBUG.p("adding: " + alarm +
    83                 " next UID: " + mDataStore.getAutoSyncNextUID());
    84113        index = mDataStore.addRecord(alarm.toByteArray());
    85114        alarm.setUID(mDataStore.getRecordUID(index));
    86         DEBUG.p("added UID " + alarm.getUID() + " @ " + index);
     115        DEBUG.p("ADD" + alarm.description());
    87116    }
    88117
     
    95124            return;
    96125        mDataStore.removeRecordByUID(uid);
    97         DEBUG.p("removed UID " + alarm.getUID());
     126        if (uid < 0)
     127            mDataStore.removeRecordByUID(-uid);
     128        DEBUG.p("DEL" + alarm.description());
    98129    }
    99130
     
    103134        Alarm alarm = (Alarm)item;
    104135        mDataStore.setRecordDataByUID(alarm.getUID(), alarm.toByteArray(), true);
    105         DEBUG.p("updated: " + alarm + " UID " + alarm.getUID());
     136        DEBUG.p("MOD" + alarm.description());
    106137    }
    107138
     
    137168            } else if (e.type == Event.EVENT_DATASTORE_RESTORED) {
    138169                String dbName = (String)e.argument;
    139                 DEBUG.p("DATASTORE_RESTORED: " + dbName);
    140                 if (!dbName.endsWith("alarms")) {
     170                DEBUG.p("Pester: DATASTORE_RESTORED " + dbName);
     171                if (dbName.endsWith("alarms")) {
    141172                    // because we only get/set the default alarm on demand
    142173                    // there's no need to handle conflicts with the settings...
Note: See TracChangeset for help on using the changeset viewer.