success = saveDecryptedAttachment (NULL, outname);
MapiGPGMEImpl::processAttachment (LPATTACH *attm, HWND hwnd,                                  int pos, int action){        LPATTACH att = *attm;    int method = getAttachMethod (att);    BOOL success = TRUE;    HRESULT hr;    /* XXX: sign-only code is still not very intuitive. */    if (action == GPG_ATTACH_NONE)	return FALSE;    if (action == GPG_ATTACH_DECRYPT && !saveDecryptedAtt)	return TRUE;    switch (method) {    case ATTACH_EMBEDDED_MSG:	LPMESSAGE emb;	/* we do not support to sign these kind of attachments. */	if (action == GPG_ATTACH_SIGN)	    return TRUE;	hr = att->OpenProperty (PR_ATTACH_DATA_OBJ, &IID_IMessage, 0, 			        MAPI_MODIFY, (LPUNKNOWN*) &emb);	if (FAILED (hr))	    return FALSE;//FIXME 	setWindow (hwnd);// 	setMessage (emb);	if (doCmdAttach (action))	    success = FALSE;	emb->SaveChanges (FORCE_SAVE);	att->SaveChanges (FORCE_SAVE);	emb->Release ();	break;    case ATTACH_BY_VALUE:	char *inname;	char *outname;	char *tmp;	tmp = getAttachFilename (att);	inname =  generateTempname (tmp);	log_debug ("enc inname: '%s'\n", inname);	if (action != GPG_ATTACH_DECRYPT) {	    char *tmp2 = (char *)xcalloc (1, strlen (inname) 					     + strlen (ATT_PREFIX) + 4 + 1);	    sprintf (tmp2, "%s"ATT_PREFIX".%s", tmp, getPGPExtension (action));	    outname = generateTempname (tmp2);	    xfree (tmp2);	    log_debug ( "enc outname: '%s'\n", outname);	}	else {	    if (checkAttachmentExtension (strrchr (tmp, '.')) == false) {		log_debug ( "%s: no pgp extension found.\n", tmp);		xfree (tmp);		xfree (inname);		return TRUE;	    }	    char *tmp2 = (char*)xcalloc (1, strlen (tmp) + 4);	    strcpy (tmp2, tmp);	    tmp2[strlen (tmp2) - 4] = '\0';	    outname = generateTempname (tmp2);	    xfree (tmp2);	    log_debug ("dec outname: '%s'\n", outname);	}	success = FALSE;	/* if we are in sign-only mode, just create a detached signature	   for each attachment but do not alter the attachment data itself. */	if (action != GPG_ATTACH_SIGN && streamOnFile (inname, att)) {	    if (doCmdFile (action, inname, outname))		success = TRUE;	    else		log_debug ( "doCmdFile failed\n");	}	if ((action == GPG_ATTACH_ENCRYPT || action == GPG_ATTACH_SIGN) 	    && autoSignAtt)	    signAttachment (inname);	/*DeleteFile (inname);*/	/* XXX: the file does not seemed to be closed. */	xfree (inname);	xfree (tmp);		if (action != GPG_ATTACH_SIGN)	    deleteAttachment (NULL/*FIXME*/,pos);	if (action == GPG_ATTACH_ENCRYPT) {	    LPATTACH newatt;	    *attm = newatt = createAttachment (NULL/*FIXME*/,pos);	    setAttachMethod (newatt, ATTACH_BY_VALUE);	    setAttachFilename (newatt, outname, false);	    if (streamFromFile (outname, newatt)) {		log_debug ( "commit changes.\n");	    		newatt->SaveChanges (FORCE_SAVE);	    }	}	else if (success && action == GPG_ATTACH_DECRYPT) {	    success = saveDecryptedAttachment (NULL, outname);	    log_debug ("saveDecryptedAttachment ec=%d\n", success);	}	DeleteFile (outname);	xfree (outname);	releaseAttachment (att);	break;    case ATTACH_BY_REF_ONLY:	break;    case ATTACH_OLE:	break;    }    return success;}