DebugFile.writeln("Begin HtmlMimeBodyPart.removePreffixFromImgSrcs("+sPreffix+")");
DebugFile.incIdent();
}
int iSlash;
Parser oPrsr;
String sCid, sSrc;
String sBodyCid = sBody;
NodeList oCollectionList;
TagNameFilter oImgFilter;
// **********************************************************************
// Replace <IMG SRC="..." >
oPrsr = Parser.createParser(sBodyCid, sEnc);
oCollectionList = new NodeList();
oImgFilter = new TagNameFilter ("IMG");
for (NodeIterator e = oPrsr.elements(); e.hasMoreNodes();)
e.nextNode().collectInto(oCollectionList, oImgFilter);
int nImgs = oCollectionList.size();
if (DebugFile.trace) DebugFile.writeln("Images NodeList.size() = " + String.valueOf(nImgs));
for (int i=0; i<nImgs; i++) {
sSrc = (((ImageTag) oCollectionList.elementAt(i)).extractImageLocn()).replace('\\','/');
// Keep a reference to every related image name so that the same image is not included twice in the message
if (!oImgs.containsKey(sSrc)) {
// Find last slash from image url
iSlash = sSrc.lastIndexOf('/');
// Take image name
if (iSlash>=0) {
while (sSrc.charAt(iSlash)=='/') { if (++iSlash==sSrc.length()) break; }
sCid = sSrc.substring(iSlash);
}
else {
sCid = sSrc;
}
// String sUid = Gadgets.generateUUID();
// sCid = sUid.substring(0,12)+"$"+sUid.substring(12,20)+"$"+sUid.substring(20,28)+"@hipergate.org";
if (DebugFile.trace) DebugFile.writeln("HashMap.put("+sSrc+","+sCid+")");
oImgs.put(sSrc, sCid);
} // fi (!oImgs.containsKey(sSrc))
String sImgSrc = ((ImageTag) oCollectionList.elementAt(i)).extractImageLocn();
if (sImgSrc.startsWith(sPreffix)) {
sBodyCid = doSubstitution(sBodyCid, "Src", Gadgets.replace(Gadgets.replace(sImgSrc,'\\',"\\\\"),'.',"\\x2E"), sImgSrc.substring(sPreffix.length()));
}
} // next
// **********************************************************************
// Replace <TABLE BACKGROUND="..." >
oCollectionList = new NodeList();
TagNameFilter oTableFilter = new TagNameFilter("TABLE");
oPrsr = Parser.createParser(sBodyCid, sEnc);
for (NodeIterator e = oPrsr.elements(); e.hasMoreNodes();)
e.nextNode().collectInto(oCollectionList, oTableFilter);
nImgs = oCollectionList.size();
if (DebugFile.trace) DebugFile.writeln("Tables NodeList.size() = " + String.valueOf(nImgs));
for (int i=0; i<nImgs; i++) {
sSrc = ((TableTag) oCollectionList.elementAt(i)).getAttribute("background");
if (sSrc!=null) {
if (sSrc.length()>0) {
sSrc = sSrc.replace('\\','/');
// Keep a reference to every related image name so that the same image is not included twice in the message
if (!oImgs.containsKey(sSrc)) {
// Find last slash from image url
iSlash = sSrc.lastIndexOf('/');
// Take image name
if (iSlash>=0) {
while (sSrc.charAt(iSlash)=='/') { if (++iSlash==sSrc.length()) break; }
sCid = sSrc.substring(iSlash);
} // fi
else {
sCid = sSrc;
}
if (DebugFile.trace) DebugFile.writeln("HashMap.put("+sSrc+","+sCid+")");
oImgs.put(sSrc, sCid);
} // fi (!oImgs.containsKey(sSrc))
String sBckGrnd = ((TableTag) oCollectionList.elementAt(i)).getAttribute("background");
if (sBckGrnd.startsWith(sPreffix)) {
sBodyCid = doSubstitution(sBodyCid, "Background", Gadgets.replace(Gadgets.replace(sBckGrnd,'\\',"\\\\"),'.',"\\x2E"), sBckGrnd.substring(sPreffix.length()));
}
} // fi
} // fi
} // next
// **********************************************************************
// Replace <TD BACKGROUND="..." >
oCollectionList = new NodeList();
TagNameFilter oTDFilter = new TagNameFilter("TD");
oPrsr = Parser.createParser(sBodyCid, sEnc);
for (NodeIterator e = oPrsr.elements(); e.hasMoreNodes();)
e.nextNode().collectInto(oCollectionList, oTDFilter);
nImgs = oCollectionList.size();
if (DebugFile.trace) DebugFile.writeln("TD NodeList.size() = " + String.valueOf(nImgs));