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));
}
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;
}
}
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;
}
}
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;
}
Aggregations