mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
167 lines
3.5 KiB
Java
167 lines
3.5 KiB
Java
/*
|
|
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
|
|
|
This file was derived from
|
|
|
|
Copyright 2007 Naomaru Itoi <nao@phoneid.org>
|
|
|
|
This file was derived from
|
|
|
|
Java clone of KeePass - A KeePass file viewer for Java
|
|
Copyright 2006 Bill Zwicky <billzwicky@users.sourceforge.net>
|
|
|
|
*
|
|
* This file is part of KeePass DX.
|
|
*
|
|
* KeePass DX is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* KeePass DX is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
package com.keepassdroid.database;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
|
|
import com.keepassdroid.utils.Types;
|
|
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author Brian Pellin <bpellin@gmail.com>
|
|
* @author Naomaru Itoi <nao@phoneid.org>
|
|
* @author Bill Zwicky <wrzwicky@pobox.com>
|
|
* @author Dominik Reichl <dominik.reichl@t-online.de>
|
|
*/
|
|
public class PwGroupV3 extends PwGroup {
|
|
|
|
public String toString() {
|
|
return name;
|
|
}
|
|
|
|
public static final Date NEVER_EXPIRE = PwEntryV3.NEVER_EXPIRE;
|
|
|
|
/** Size of byte buffer needed to hold this struct. */
|
|
public static final int BUF_SIZE = 124;
|
|
|
|
// for tree traversing
|
|
public PwGroupV3 parent = null;
|
|
|
|
public int groupId;
|
|
|
|
public PwDate tCreation;
|
|
public PwDate tLastMod;
|
|
public PwDate tLastAccess;
|
|
public PwDate tExpire;
|
|
|
|
public int level; // short
|
|
|
|
/** Used by KeePass internally, don't use */
|
|
public int flags;
|
|
|
|
public void setGroups(List<PwGroup> groups) {
|
|
childGroups = groups;
|
|
}
|
|
|
|
@Override
|
|
public PwGroup getParent() {
|
|
return parent;
|
|
}
|
|
|
|
@Override
|
|
public PwGroupId getId() {
|
|
return new PwGroupIdV3(groupId);
|
|
}
|
|
|
|
@Override
|
|
public void setId(PwGroupId id) {
|
|
PwGroupIdV3 id3 = (PwGroupIdV3) id;
|
|
groupId = id3.getId();
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
@Override
|
|
public Date getLastMod() {
|
|
return tLastMod.getJDate();
|
|
}
|
|
|
|
@Override
|
|
public void setParent(PwGroup prt) {
|
|
parent = (PwGroupV3) prt;
|
|
level = parent.level + 1;
|
|
|
|
}
|
|
|
|
@Override
|
|
public void initNewGroup(String nm, PwGroupId newId) {
|
|
super.initNewGroup(nm, newId);
|
|
|
|
Date now = Calendar.getInstance().getTime();
|
|
tCreation = new PwDate(now);
|
|
tLastAccess = new PwDate(now);
|
|
tLastMod = new PwDate(now);
|
|
tExpire = new PwDate(PwGroupV3.NEVER_EXPIRE);
|
|
|
|
}
|
|
|
|
public void populateBlankFields(PwDatabaseV3 db) {
|
|
if (icon == null) {
|
|
icon = db.iconFactory.getIcon(1);
|
|
}
|
|
|
|
if (name == null) {
|
|
name = "";
|
|
}
|
|
|
|
if (tCreation == null) {
|
|
tCreation = PwEntryV3.DEFAULT_PWDATE;
|
|
}
|
|
|
|
if (tLastMod == null) {
|
|
tLastMod = PwEntryV3.DEFAULT_PWDATE;
|
|
}
|
|
|
|
if (tLastAccess == null) {
|
|
tLastAccess = PwEntryV3.DEFAULT_PWDATE;
|
|
}
|
|
|
|
if (tExpire == null) {
|
|
tExpire = PwEntryV3.DEFAULT_PWDATE;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setLastAccessTime(Date date) {
|
|
tLastAccess = new PwDate(date);
|
|
}
|
|
|
|
@Override
|
|
public void setLastModificationTime(Date date) {
|
|
tLastMod = new PwDate(date);
|
|
}
|
|
|
|
@Override
|
|
public Date getCreationTime() {
|
|
if(tCreation != null)
|
|
return tCreation.getJDate();
|
|
else
|
|
return new Date();
|
|
}
|
|
}
|