Search in sources :

Example 1 with PwDate

use of com.keepassdroid.database.PwDate in project KeePassDX by Kunzisoft.

the class PwDateTest method testDate.

public void testDate() {
    PwDate jDate = new PwDate(System.currentTimeMillis());
    PwDate intermediate = (PwDate) jDate.clone();
    PwDate cDate = new PwDate(intermediate.getCDate(), 0);
    assertTrue("jDate and intermediate not equal", jDate.equals(intermediate));
    assertTrue("jDate and cDate not equal", cDate.equals(jDate));
}
Also used : PwDate(com.keepassdroid.database.PwDate)

Example 2 with PwDate

use of com.keepassdroid.database.PwDate in project keepass2android by PhilippC.

the class ImporterV3 method readEntryField.

void readEntryField(PwDatabaseV3 db, PwEntryV3 ent, byte[] buf, int offset) throws UnsupportedEncodingException {
    int fieldType = LEDataInputStream.readUShort(buf, offset);
    offset += 2;
    int fieldSize = LEDataInputStream.readInt(buf, offset);
    offset += 4;
    switch(fieldType) {
        case 0x0000:
            // Ignore field
            break;
        case 0x0001:
            ent.setUUID(Types.bytestoUUID(buf, offset));
            break;
        case 0x0002:
            ent.groupId = LEDataInputStream.readInt(buf, offset);
            break;
        case 0x0003:
            int iconId = LEDataInputStream.readInt(buf, offset);
            // Clean up after bug that set icon ids to -1
            if (iconId == -1) {
                iconId = 0;
            }
            ent.icon = db.iconFactory.getIcon(iconId);
            break;
        case 0x0004:
            ent.title = Types.readCString(buf, offset);
            break;
        case 0x0005:
            ent.url = Types.readCString(buf, offset);
            break;
        case 0x0006:
            ent.username = Types.readCString(buf, offset);
            break;
        case 0x0007:
            ent.setPassword(buf, offset, Types.strlen(buf, offset));
            break;
        case 0x0008:
            ent.additional = Types.readCString(buf, offset);
            break;
        case 0x0009:
            ent.tCreation = new PwDate(buf, offset);
            break;
        case 0x000A:
            ent.tLastMod = new PwDate(buf, offset);
            break;
        case 0x000B:
            ent.tLastAccess = new PwDate(buf, offset);
            break;
        case 0x000C:
            ent.tExpire = new PwDate(buf, offset);
            break;
        case 0x000D:
            ent.binaryDesc = Types.readCString(buf, offset);
            break;
        case 0x000E:
            ent.setBinaryData(buf, offset, fieldSize);
            break;
    }
}
Also used : PwDate(com.keepassdroid.database.PwDate)

Example 3 with PwDate

use of com.keepassdroid.database.PwDate in project KeePassDX by Kunzisoft.

the class ImporterV3 method readEntryField.

void readEntryField(PwDatabaseV3 db, PwEntryV3 ent, byte[] buf, int offset) throws UnsupportedEncodingException {
    int fieldType = LEDataInputStream.readUShort(buf, offset);
    offset += 2;
    int fieldSize = LEDataInputStream.readInt(buf, offset);
    offset += 4;
    switch(fieldType) {
        case 0x0000:
            // Ignore field
            break;
        case 0x0001:
            ent.setUUID(Types.bytestoUUID(buf, offset));
            break;
        case 0x0002:
            ent.setGroupId(LEDataInputStream.readInt(buf, offset));
            break;
        case 0x0003:
            int iconId = LEDataInputStream.readInt(buf, offset);
            // Clean up after bug that set icon ids to -1
            if (iconId == -1) {
                iconId = 0;
            }
            ent.setIcon(db.iconFactory.getIcon(iconId));
            break;
        case 0x0004:
            ent.setTitle(Types.readCString(buf, offset));
            break;
        case 0x0005:
            ent.setUrl(Types.readCString(buf, offset));
            break;
        case 0x0006:
            ent.setUsername(Types.readCString(buf, offset));
            break;
        case 0x0007:
            ent.setPassword(buf, offset, Types.strlen(buf, offset));
            break;
        case 0x0008:
            ent.setNotes(Types.readCString(buf, offset));
            break;
        case 0x0009:
            ent.setCreationTime(new PwDate(buf, offset));
            break;
        case 0x000A:
            ent.setLastModificationTime(new PwDate(buf, offset));
            break;
        case 0x000B:
            ent.setLastAccessTime(new PwDate(buf, offset));
            break;
        case 0x000C:
            ent.setExpiryTime(new PwDate(buf, offset));
            break;
        case 0x000D:
            ent.setBinaryDesc(Types.readCString(buf, offset));
            break;
        case 0x000E:
            ent.setBinaryData(buf, offset, fieldSize);
            break;
    }
}
Also used : PwDate(com.keepassdroid.database.PwDate)

Example 4 with PwDate

use of com.keepassdroid.database.PwDate in project KeePassDX by Kunzisoft.

the class EntryEditActivity method populateNewEntry.

protected PwEntry populateNewEntry() {
    PwDatabase db = App.getDB().pm;
    PwEntry newEntry = mEntry.clone();
    newEntry.startToDecodeReference(db);
    newEntry.createBackup(db);
    newEntry.setLastAccessTime(new PwDate());
    newEntry.setLastModificationTime(new PwDate());
    newEntry.setTitle(entryTitleView.getText().toString());
    if (mSelectedIconID != -1)
        // or TODO icon factory newEntry.setIcon(App.getDB().pm.iconFactory.getIcon(mSelectedIconID));
        newEntry.setIcon(new PwIconStandard(mSelectedIconID));
    else {
        if (mIsNew) {
            newEntry.setIcon(App.getDB().pm.iconFactory.getIcon(0));
        } else {
            //  Keep previous icon, if no new one was selected
            newEntry.setIcon(mEntry.getIconStandard());
        }
    }
    newEntry.setUrl(entryUrlView.getText().toString());
    newEntry.setUsername(entryUserNameView.getText().toString());
    newEntry.setNotes(entryCommentView.getText().toString());
    newEntry.setPassword(entryPasswordView.getText().toString());
    if (newEntry.allowExtraFields()) {
        // Delete all new standard strings
        newEntry.removeExtraFields();
        // Add extra fields from views
        for (int i = 0; i < entryExtraFieldsContainer.getChildCount(); i++) {
            EntryEditNewField view = (EntryEditNewField) entryExtraFieldsContainer.getChildAt(i);
            String key = view.getLabel();
            String value = view.getValue();
            boolean protect = view.isProtected();
            newEntry.addField(key, new ProtectedString(protect, value));
        }
    }
    newEntry.endToDecodeReference(db);
    return newEntry;
}
Also used : PwDatabase(com.keepassdroid.database.PwDatabase) PwDate(com.keepassdroid.database.PwDate) PwEntry(com.keepassdroid.database.PwEntry) ProtectedString(com.keepassdroid.database.security.ProtectedString) PwIconStandard(com.keepassdroid.database.PwIconStandard) ProtectedString(com.keepassdroid.database.security.ProtectedString) EntryEditNewField(com.keepassdroid.view.EntryEditNewField)

Aggregations

PwDate (com.keepassdroid.database.PwDate)4 PwDatabase (com.keepassdroid.database.PwDatabase)1 PwEntry (com.keepassdroid.database.PwEntry)1 PwIconStandard (com.keepassdroid.database.PwIconStandard)1 ProtectedString (com.keepassdroid.database.security.ProtectedString)1 EntryEditNewField (com.keepassdroid.view.EntryEditNewField)1