use of com.keepassdroid.database.PwIconCustom in project KeePassDX by Kunzisoft.
the class PwDbV4Output method writeCustomIconList.
private void writeCustomIconList() throws IllegalArgumentException, IllegalStateException, IOException {
List<PwIconCustom> customIcons = mPM.customIcons;
if (customIcons.size() == 0)
return;
xml.startTag(null, ElemCustomIcons);
for (PwIconCustom icon : customIcons) {
xml.startTag(null, ElemCustomIconItem);
writeObject(ElemCustomIconItemID, icon.uuid);
writeObject(ElemCustomIconItemData, String.valueOf(Base64Coder.encode(icon.imageData)));
xml.endTag(null, ElemCustomIconItem);
}
xml.endTag(null, ElemCustomIcons);
}
use of com.keepassdroid.database.PwIconCustom in project KeePassDX by Kunzisoft.
the class ImporterV4 method EndXmlElement.
private KdbContext EndXmlElement(KdbContext ctx, XmlPullParser xpp) throws XmlPullParserException {
assert (xpp.getEventType() == XmlPullParser.END_TAG);
String name = xpp.getName();
if (ctx == KdbContext.KeePassFile && name.equalsIgnoreCase(ElemDocNode)) {
return KdbContext.Null;
} else if (ctx == KdbContext.Meta && name.equalsIgnoreCase(ElemMeta)) {
return KdbContext.KeePassFile;
} else if (ctx == KdbContext.Root && name.equalsIgnoreCase(ElemRoot)) {
return KdbContext.KeePassFile;
} else if (ctx == KdbContext.MemoryProtection && name.equalsIgnoreCase(ElemMemoryProt)) {
return KdbContext.Meta;
} else if (ctx == KdbContext.CustomIcons && name.equalsIgnoreCase(ElemCustomIcons)) {
return KdbContext.Meta;
} else if (ctx == KdbContext.CustomIcon && name.equalsIgnoreCase(ElemCustomIconItem)) {
if (!customIconID.equals(PwDatabase.UUID_ZERO)) {
PwIconCustom icon = new PwIconCustom(customIconID, customIconData);
db.customIcons.add(icon);
db.iconFactory.put(icon);
} else
assert (false);
customIconID = PwDatabase.UUID_ZERO;
customIconData = null;
return KdbContext.CustomIcons;
} else if (ctx == KdbContext.Binaries && name.equalsIgnoreCase(ElemBinaries)) {
return KdbContext.Meta;
} else if (ctx == KdbContext.CustomData && name.equalsIgnoreCase(ElemCustomData)) {
return KdbContext.Meta;
} else if (ctx == KdbContext.CustomDataItem && name.equalsIgnoreCase(ElemStringDictExItem)) {
if (customDataKey != null && customDataValue != null) {
db.customData.put(customDataKey, customDataValue);
} else
assert (false);
customDataKey = null;
customDataValue = null;
return KdbContext.CustomData;
} else if (ctx == KdbContext.Group && name.equalsIgnoreCase(ElemGroup)) {
if (ctxGroup.getUUID() == null || ctxGroup.getUUID().equals(PwDatabase.UUID_ZERO)) {
ctxGroup.setUUID(UUID.randomUUID());
}
ctxGroups.pop();
if (ctxGroups.size() == 0) {
ctxGroup = null;
return KdbContext.Root;
} else {
ctxGroup = ctxGroups.peek();
return KdbContext.Group;
}
} else if (ctx == KdbContext.GroupTimes && name.equalsIgnoreCase(ElemTimes)) {
return KdbContext.Group;
} else if (ctx == KdbContext.GroupCustomData && name.equalsIgnoreCase(ElemCustomData)) {
return KdbContext.Group;
} else if (ctx == KdbContext.GroupCustomDataItem && name.equalsIgnoreCase(ElemStringDictExItem)) {
if (groupCustomDataKey != null && groupCustomDataValue != null) {
ctxGroup.putCustomData(groupCustomDataKey, groupCustomDataKey);
} else {
assert (false);
}
groupCustomDataKey = null;
groupCustomDataValue = null;
return KdbContext.GroupCustomData;
} else if (ctx == KdbContext.Entry && name.equalsIgnoreCase(ElemEntry)) {
if (ctxEntry.getUUID() == null || ctxEntry.getUUID().equals(PwDatabase.UUID_ZERO)) {
ctxEntry.setUUID(UUID.randomUUID());
}
if (entryInHistory) {
ctxEntry = ctxHistoryBase;
return KdbContext.EntryHistory;
}
return KdbContext.Group;
} else if (ctx == KdbContext.EntryTimes && name.equalsIgnoreCase(ElemTimes)) {
return KdbContext.Entry;
} else if (ctx == KdbContext.EntryString && name.equalsIgnoreCase(ElemString)) {
ctxEntry.addField(ctxStringName, ctxStringValue);
ctxStringName = null;
ctxStringValue = null;
return KdbContext.Entry;
} else if (ctx == KdbContext.EntryBinary && name.equalsIgnoreCase(ElemBinary)) {
ctxEntry.putProtectedBinary(ctxBinaryName, ctxBinaryValue);
ctxBinaryName = null;
ctxBinaryValue = null;
return KdbContext.Entry;
} else if (ctx == KdbContext.EntryAutoType && name.equalsIgnoreCase(ElemAutoType)) {
return KdbContext.Entry;
} else if (ctx == KdbContext.EntryAutoTypeItem && name.equalsIgnoreCase(ElemAutoTypeItem)) {
ctxEntry.getAutoType().put(ctxATName, ctxATSeq);
ctxATName = null;
ctxATSeq = null;
return KdbContext.EntryAutoType;
} else if (ctx == KdbContext.EntryCustomData && name.equalsIgnoreCase(ElemCustomData)) {
return KdbContext.Entry;
} else if (ctx == KdbContext.EntryCustomDataItem && name.equalsIgnoreCase(ElemStringDictExItem)) {
if (entryCustomDataKey != null && entryCustomDataValue != null) {
ctxEntry.putCustomData(entryCustomDataKey, entryCustomDataValue);
} else {
assert (false);
}
entryCustomDataKey = null;
entryCustomDataValue = null;
return KdbContext.EntryCustomData;
} else if (ctx == KdbContext.EntryHistory && name.equalsIgnoreCase(ElemHistory)) {
entryInHistory = false;
return KdbContext.Entry;
} else if (ctx == KdbContext.RootDeletedObjects && name.equalsIgnoreCase(ElemDeletedObjects)) {
return KdbContext.Root;
} else if (ctx == KdbContext.DeletedObject && name.equalsIgnoreCase(ElemDeletedObject)) {
ctxDeletedObject = null;
return KdbContext.RootDeletedObjects;
} else {
assert (false);
String contextName = "";
if (ctx != null) {
contextName = ctx.name();
}
throw new RuntimeException("Invalid end element: Context " + contextName + "End element: " + name);
}
}
use of com.keepassdroid.database.PwIconCustom in project KeePassDX by Kunzisoft.
the class PwEntryTestV4 method testAssign.
public void testAssign() {
PwEntryV4 entry = new PwEntryV4();
entry.setAdditional("test223");
entry.setAutoType(new AutoType());
entry.getAutoType().defaultSequence = "1324";
entry.getAutoType().enabled = true;
entry.getAutoType().obfuscationOptions = 123412432109L;
entry.getAutoType().put("key", "value");
entry.setBackgroupColor("blue");
entry.putProtectedBinary("key1", new ProtectedBinary(false, new byte[] { 0, 1 }));
entry.setCustomIcon(new PwIconCustom(UUID.randomUUID(), new byte[0]));
entry.setForegroundColor("red");
entry.addToHistory(new PwEntryV4());
entry.setIcon(new PwIconStandard(5));
entry.setOverrideURL("override");
entry.setParent(new PwGroupV4());
entry.addField("key2", new ProtectedString(false, "value2"));
entry.setUrl("http://localhost");
entry.setUUID(UUID.randomUUID());
PwEntryV4 target = new PwEntryV4();
target.assign(entry);
/* This test is not so useful now that I am not implementing value equality for Entries
assertTrue("Entries do not match.", entry.equals(target));
*/
}
Aggregations