DWORD CLotusNote::ItemInfo(char *item_name, BLOCKID *item_blockid, WORD *item_datatype, BLOCKID *value_blockid, DWORD *value_len) { WORD size = 0; if (m_hnote == NULL) return Error_Handle("GetItemInfo ... failed"); if (item_name != NULL) size = strlen(item_name); return CLotusSection::Add_NApi_code_msg(NSFItemInfo(m_hnote,item_name,size,item_blockid,item_datatype,value_blockid,value_len),SSIZE(m_err_msg),"CLotusNote::ItemInfo->NSFItemInfo"); }
_declspec( dllexport ) STATUS ATOM_NSFItemInfo(NOTEHANDLE note_handle, const char far *item_name, WORD name_len, BLOCKID far *item_blockid, WORD far *value_datatype, BLOCKID far *value_blockid, DWORD far *value_len) { return NSFItemInfo(note_handle, item_name, name_len, item_blockid, value_datatype, value_blockid, value_len); }
/** eus_MimePartItmInfo( *** Provides certain requested information about a particular MIME-part item in a note. --- parameters & return ---- h_NOTE: handle to the note containing the MIME content pc_ITMNM: address of the name of the item containing the MIME content us_LEN_ITMNM_: Optional. Length of the item's name. If null, procedure will assume the name to be null-terminated and will compute the length itself. bid_ITM_PRV: Optional. Address of the _item_ BlockID of the same-named item that precedes the item being queried. Therefore only useful when working with multiple-instance items. If null, procedure seeks the first item with the given name. pbid_itm: Optional Output. Address of the variable to receive the item BlockID of the target item. If null, output is suppressed. pbid_ctnt: Optional Output, Required if the content-descriptor output is requested. Address of the variable to receive the content BlockID of the target item. If the content-descriptor output is requested, the block will be locked on return and the caller is responsible for unlocking it. If null, output is suppressed. If a handled error occurs, block will be unlocked before return. pt_ctnt: Optional Output. Address of the content-descriptor structure to receive information about the content of the MIME-part. If null, output is suppressed. pbid_itmFileIncl: Optional Output. Address of BlockID to receive the _item_ block associated with the file-attacment include involved with the MIME-part. pbid_ctntFileIncl: Optional Output. Address of BlockID to receive the content block associated with the file-attacment include involved with the MIME-part. If null, the output is suppressed. RETURN: eus_ERR_INVLD_ARG if any input is obviously invalid eus_ERR_MEM if an attempted memory allocation failed eus_SUCCESS if no error occured the Notes API error code otherwise --- revision history ------- 3/14/03 PR: created */ STATUS eus_MimePartItmInfo( const NOTEHANDLE h_NOTE, const char pc_ITMNM[], const WORD us_LEN_ITMNM_, const BLOCKID bid_ITM_PRV, BLOCKID *const pbid_itm, BLOCKID *const pbid_ctnt, MimePrtItmCtnt *const pt_ctnt, BLOCKID *const pbid_itmFileIncl, BLOCKID *const pbid_ctntFileIncl) { const WORD us_LEN_ITMNM = us_LEN_ITMNM_ ? us_LEN_ITMNM_ : pc_ITMNM ? strlen( pc_ITMNM) : NULL; BLOCKID bid_ctnt; WORD us_typ, us_lenCtnt; DWORD ul; MIME_PART * pt; BYTE * puc_ctnt, * puc; WORD us; STATUS us_err; if (!( h_NOTE && pc_ITMNM && *pc_ITMNM && (pt_ctnt ? (BOOL) pbid_ctnt : TRUE))) return eus_ERR_INVLD_ARG; if (pbid_itm) *pbid_itm = ebid_NULLBLOCKID; if (pbid_ctnt) *pbid_ctnt = ebid_NULLBLOCKID; if (pt_ctnt) memset( pt_ctnt, NULL, sizeof( MimePrtItmCtnt)); if (pbid_itmFileIncl) *pbid_itmFileIncl = ebid_NULLBLOCKID; if (pbid_ctntFileIncl) *pbid_ctntFileIncl = ebid_NULLBLOCKID; //if the item isn't a valid MIME-part, short-cicuit with failure if (!bid_ITM_PRV.pool) { if (us_err = NSFItemInfo( (NOTEHANDLE) h_NOTE, (char *) pc_ITMNM, us_LEN_ITMNM, pbid_itm, &us_typ, &bid_ctnt, &ul)) return us_err; }else if (us_err = NSFItemInfoNext( (NOTEHANDLE) h_NOTE, bid_ITM_PRV, (char *) pc_ITMNM, us_LEN_ITMNM, pbid_itm, &us_typ, &bid_ctnt, &ul)) return us_err; if (!( us_typ == TYPE_MIME_PART && ul >= sizeof( WORD) + sizeof( MIME_PART))) return eus_ERR_INVLD_ARG; //if request requires no content annotatation or extraction, short-circuit // with success if (!( pt_ctnt || pbid_itmFileIncl || pbid_ctntFileIncl)) { if (pbid_ctnt) *pbid_ctnt = bid_ctnt; return eus_SUCCESS; } //annotate and extract content as requested pt = (MIME_PART *) (OSLockBlock( WORD, bid_ctnt) + 1); puc_ctnt = puc = (BYTE *) (pt + 1); if (pt_ctnt) { pt_ctnt->puc_ctnt = puc_ctnt; pt_ctnt->pt = pt; } us_lenCtnt = pt->wByteCount; if (puc = epc_strInBuf( epc_MIMHDR_CTNT_TYP, puc, us_lenCtnt, eus_LEN_MIMHDR_CTNT_TYP)) { puc += eus_LEN_MIMHDR_CTNT_TYP; if (pt_ctnt) pt_ctnt->puc_typ = puc; if (!( puc = epc_strInBuf( epc_MIM_HDRS_DLIM, puc, us_lenCtnt, eus_LEN_MIM_HDRS_DLIM))) goto errJump; puc += eus_LEN_MIM_HDRS_DLIM; if (pt_ctnt) pt_ctnt->puc_bdy = puc; if (pt->dwFlags & MIME_PART_BODY_IN_DBOBJECT && (pbid_itmFileIncl || pbid_ctntFileIncl) && (us = pt->wByteCount - (puc - puc_ctnt)) && us < MAXPATH) { char *const pc = malloc( us + 1); if (!pc) { us_err = eus_ERR_MEM; goto errJump; } pc[ us] = NULL; memcpy( pc, puc, us); us_err = eus_getAttachmentInfo( h_NOTE, NULL, pc, NULL, NULL, NULL, NULL, pbid_itmFileIncl, pbid_ctntFileIncl); if (!us_err && (pbid_itmFileIncl && pbid_itmFileIncl->pool || pbid_ctntFileIncl && pbid_ctntFileIncl->pool)) pt_ctnt->pc_objNm = pc; else free( pc); if (us_err) goto errJump; } //if (pt->dwFlags & MIME_PART_BODY_IN_DBOBJECT && (pbid_itmFileIncl || }else if (us_lenCtnt > pt->wBoundaryLen + eus_LEN_MIM_BNDRY_TACK_ON + eui_LEN_CRLF) goto errJump; if (!pt_ctnt) OSUnlockBlock( bid_ctnt); if (pbid_ctnt) *pbid_ctnt = bid_ctnt; return eus_SUCCESS; errJump: OSUnlockBlock( bid_ctnt); return us_err ? us_err : eus_ERR_INVLD_ARG; } //eus_MimePartItmInfo(
/** eus_ReplaceDesignNote( *** Replaces the specified design-element note in a target database with its given counterpart in a source database. Any "Do Not Replace/Refresh" property on the design note in the target database is ignored. Upon replacement, any specified design-class property is set and the "Do Not Replace/Refresh" property is set to false. --- parameters & return ----- h_DB_TARGET: handle to the target database us_NOTE_CLASS: the class of the note to be removed from the target database and, if the class is a unique-note class and the source NoteID was not provided (nid_SRC), the class of the replacement note in the source database pc_NOTENM: Optional. Pointer to the name of the design-element note to be removed from the target database. Required if the note class (us_NOTE_CLASS) is not of the unique-note type. If the note class is of the unique-note type, the parameter is ignored. h_DB_SRC: handle to the source database nid_SRC: Optional. NoteID of the replacement design-element. Required if the note class is not of the unique-note type. If of the unique-note type and not provided, procedure will look up the counterpart replacement note using the note-class parameter. pc_CLASSTITLE: Optional. For design element of non-unique type, pointer to the design-class name to use if the caller wishes to set the design-class property on the replacement design element. For icon notes, parameter serves instead as a flag to indicate whether the $TITLE item on the icon note to be replaced should replace the $TITLE item on the replacement note. (The $TITLE item contains the database title, class name, design-class name and database categories associated with the database.) Parameter is ignored if the class specified in us_NOTE_CLASS is of a different unique type. Pass NULL or the null-string if no design-class name should be set. pnid: Optional Output. Address of the variable in which to store the NoteID of the replacement note in the target database after replacement has been accomplished. If NULL on pass, output is suppressed. RETURN: eus_SUCCESS if no error occured ERR_MEMORY if insufficient-memory condition is encountered the Notes API error code otherwise --- suggested enhancement --- 9/12/99 PR: incorporate flag input for whether to honor the "Do Not Replace/Refresh" property before carrying out the replacement --- revision history -------- 2/22/00 PR + minor documentation adjustment + to prevent "corrupted note" error message in Notes 4.5.1 client, added OPEN_EXPAND flag when opening notes to be signed 9/12/99 PR + recast to accommodate replacement of any design element + completed standard documentation + moved into standard library 1/22/99 PR: created */ STATUS eus_ReplaceDesignNote( DBHANDLE h_DB_TARGET, const WORD us_NOTE_CLASS, char pc_NOTENM[], DBHANDLE h_DB_SRC, const NOTEID nid_SRC, char pc_CLASSTITLE[], NOTEID *const pnid) { const BOOL f_SPECIAL_DESIGN_NOTE = !!(us_NOTE_CLASS & NOTE_CLASS_SINGLE_INSTANCE); NOTEID nid, nid_src; NOTEHANDLE h; STATUS us_err; if (! ( h_DB_TARGET && us_NOTE_CLASS && (!pc_NOTENM ? f_SPECIAL_DESIGN_NOTE : TRUE) && h_DB_SRC && h_DB_TARGET != h_DB_SRC && (!f_SPECIAL_DESIGN_NOTE ? nid_SRC : TRUE))) return !eus_SUCCESS; if (pnid) *pnid = NULL; //if this is a unique design note we're replacing and we don't yet // have the NoteID of the replacement note, get that NoteID if (!(nid_src = nid_SRC) && f_SPECIAL_DESIGN_NOTE) if (us_err = NSFDbGetSpecialNoteID( h_DB_SRC, (WORD) (SPECIAL_ID_NOTE | us_NOTE_CLASS), &nid_src)) return us_err; //if we're replacing an icon note but the caller wishes to preserve the // current set of database information (e.g. its title)... if (NOTE_CLASS_ICON == us_NOTE_CLASS && pc_CLASSTITLE) { const WORD US = (WORD) strlen( FIELD_TITLE); BLOCKID bid; //open the icon note to be replaced if (us_err = NSFDbGetSpecialNoteID( h_DB_TARGET, (WORD) (SPECIAL_ID_NOTE | NOTE_CLASS_ICON), &nid)) { if (ERR_SPECIAL_ID != us_err) return us_err; }else { if (us_err = NSFNoteOpen( h_DB_TARGET, nid, NULL, &h)) return us_err; //if the $TITLE item for some reason isn't present... if (us_err = NSFItemInfo( h, FIELD_TITLE, US, &bid, NULL, NULL, NULL)) { if (ERR_ITEM_NOT_FOUND != us_err) goto errJump; //delete the icon note from the target database in // preparation for ensuing replacement NSFNoteClose( h); if (us_err = NSFNoteDelete( h_DB_TARGET, nid, NULL)) return us_err; //else undertake preservation of the original $TITLE item... }else { NOTEHANDLE h_mem; //create a holder note in memory and place a copy of the item // in it if (us_err = NSFNoteCreate( h_DB_TARGET, &h_mem)) goto errJump; if (us_err = NSFItemCopy( h_mem, bid)) { NSFNoteClose( h_mem); goto errJump; } //close the icon note to be replaced, then carry out the // replacement NSFNoteClose( h); if (us_err = NSFNoteDelete( h_DB_TARGET, nid, NULL)) { NSFNoteClose( h_mem); return us_err; } if (us_err = NSFDbCopyNote( h_DB_SRC, NULL, NULL, nid_src, h_DB_TARGET, NULL, NULL, &nid, NULL)) { NSFNoteClose( h_mem); return us_err; } //open the new icon note in the target database and remove // its $TITLE item if (us_err = NSFNoteOpen( h_DB_TARGET, nid, OPEN_EXPAND, &h)) { NSFNoteClose( h_mem); return us_err; } if (us_err = eus_RemoveItem( h, FIELD_TITLE, ebid_NULLBLOCKID)) { NSFNoteClose( h_mem); goto errJump; } //copy the in-memory note's $TITLE item to the icon note, // then close the in-memory note if (us_err = NSFItemInfo( h_mem, FIELD_TITLE, US, &bid, NULL, NULL, NULL)) { NSFNoteClose( h_mem); goto errJump; } us_err = NSFItemCopy( h, bid); NSFNoteClose( h_mem); if (us_err) goto errJump; //sign & save the new icon note if (us_err = NSFNoteSign( h)) goto errJump; if (us_err = NSFNoteUpdate( h, NULL)) goto errJump; } //if (us_err = NSFItemInfo( h, FIELD_TITLE, } //if (us_err = NSFDbGetSpecialNoteID( h_DB_TARGET, //if $TITLE preservation failed because the icon note or the item // itself wasn't present... if (us_err) { //open, sign, save & close the icon note in the source database if (us_err = NSFNoteOpen( h_DB_SRC, nid_src, OPEN_EXPAND, &h)) return us_err; if (us_err = NSFNoteSign( h)) goto errJump; if (us_err = NSFNoteUpdate( h, NULL)) goto errJump; NSFNoteClose( h); //copy the replacement note over to the target database if (us_err = NSFDbCopyNote( h_DB_SRC, NULL, NULL, nid_src, h_DB_TARGET, NULL, NULL, &nid, NULL)) return us_err; } //if (us_err) //else follow a regular replacement process... }else { //delete the design note from the target database if (us_err = eus_RemoveDesignNote( h_DB_TARGET, us_NOTE_CLASS, pc_NOTENM)) return us_err; //copy the note in the template to the target database if (us_err = NSFDbCopyNote( h_DB_SRC, NULL, NULL, nid_src, h_DB_TARGET, NULL, NULL, &nid, NULL)) return us_err; //if requested, change the inheritance name on the form to the class // name provided and ensure that the flag "Do not allow // Replace/Refresh to modify" is not set if (pc_CLASSTITLE && *pc_CLASSTITLE && !f_SPECIAL_DESIGN_NOTE) { char * pc_flags; if (us_err = NSFNoteOpen( h_DB_TARGET, nid, NULL, &h)) return us_err; if (us_err = eus_RemoveItem( h, DESIGN_CLASS, ebid_NULLBLOCKID)) goto errJump; if (us_err = NSFItemSetText( h, DESIGN_CLASS, pc_CLASSTITLE, (WORD) strlen( pc_CLASSTITLE))) goto errJump; if (us_err = eus_AttemptCopyTextItemContent( h, DESIGN_FLAGS, NULL, &pc_flags, NULL)) goto errJump; if (pc_flags) { char * pc = strrchr( pc_flags, DESIGN_FLAG_PRESERVE); if (pc) { if (us_err = eus_RemoveItem( h, DESIGN_FLAGS, ebid_NULLBLOCKID)) { free( pc_flags); goto errJump; } memmove( pc, pc + 1, pc_flags + strlen( pc_flags) - pc + 1); if (us_err = NSFItemSetText( h, DESIGN_FLAGS, pc_flags, (WORD) strlen( pc_flags))) { free( pc_flags); goto errJump; } } //if (pc) free( pc_flags); } //if (pc_flags) if (us_err = NSFNoteSign( h)) goto errJump; us_err = NSFNoteUpdate( h, NULL); errJump: NSFNoteClose( h); } //if (pc_CLASSTITLE && *pc_CLASSTITLE) } //if (NOTE_CLASS_ICON == us_NOTE_CLASS && if (pnid && !us_err) *pnid = nid; return us_err; } //eus_ReplaceDesignNote(