Example #1
0
void Message::SetPriority(const std::wstring& priority)
{
    if(priority.empty())
    {
        LOG_WS_ERROR(L"Failed to set the 'Priority' of a notes message - value empty");
        return;
    }

	STATUS status = NSFItemSetText(m_noteHandle, MAIL_IMPORTANCE_ITEM, Workshare::Conversions::W22LMBCS(priority.c_str()).c_str(), (WORD)priority.size());
	if(LNNOERROR != status)
		LOG_WS_ERROR(L"Failed to set the 'Priority' of a notes message");
}
Example #2
0
void Message::SetSubject(const std::wstring& subject) const
{
    if(subject.empty())
    {
        LOG_WS_ERROR(L"Subject value empty");
        return;
    }

	std::wostringstream msg;
	msg << "Set MAIL_SUBJECT_ITEM = [" << subject.c_str() << "]" << std::ends;
	LOG_WS_INFO(msg.str().c_str());
	
	std::string lmbcsString = Workshare::Conversions::W22LMBCS(subject.c_str());		
	std::vector<char> charVector(lmbcsString.begin(), lmbcsString.end());
	std::for_each(charVector.begin(), charVector.end() - 1, ConvertLineFeedCharToNullChar());
	
	STATUS status = NSFItemSetText(m_noteHandle, MAIL_SUBJECT_ITEM, &charVector[0], (WORD)charVector.size());
	if(LNNOERROR != status)
	{
		LOG_WS_ERROR(L"Failed to set the 'Subject' of a notes message");
	}
}
Example #3
0
void NotesHelper::SetMemoText(const HANDLE noteHandle, const std::string &field, const std::string data)
{
	STATUS status = NSFItemSetText(noteHandle, field.c_str(), data.c_str(), MAXWORD);
	if(NOERROR != status)
		throw CppUnitException(_T("Failed to set the note Form field"), __LINE__, _T(__FILE__));	
}
Example #4
0
DWORD CLotusNote::ItemSetText(char *item_name, char *text, WORD length)
{
	if (m_hnote == NULL) return SetError(false,ERR_HANDLE,"CLotusNote::ItemSetText ...");
	return CLotusSection::Add_NApi_code_msg(NSFItemSetText(m_hnote,item_name,text,length),SSIZE(m_err_msg),"CLotusNote::ItemSetText->NSFItemSetText(%s,%s)",item_name,text);
}
Example #5
0
void RecipientsHandler::SetNotesRecipients(const HANDLE noteHandle, const std::wstring& recipients, const AbstractRecipient::Location recipientField)
{
	if(0 == noteHandle || recipients.empty())
		return;

	std::string notesRecipientField;
	std::wstring errorMessage;

	switch(recipientField)
	{
	case AbstractRecipient::ENTERED_TO:
		notesRecipientField = MAIL_ENTERSENDTO_ITEM;
		errorMessage = L"Failed to set the enter To Recipients of notes message";
		break;
	case AbstractRecipient::ENTERED_CC:
		notesRecipientField = MAIL_ENTERCOPYTO_ITEM;
		errorMessage = L"Failed to set the enter CC Recipients of notes message";
		break;
	case AbstractRecipient::ENTERED_BCC:
		notesRecipientField = MAIL_ENTERBLINDCOPYTO_ITEM;
		errorMessage = L"Failed to set the enter BCC Recipients of notes message";
		break;
	case AbstractRecipient::SENDTO:
		notesRecipientField = MAIL_SENDTO_ITEM;
		errorMessage = L"Failed to set the To Recipients of notes message";
		break;
	case AbstractRecipient::COPYTO:
		notesRecipientField = MAIL_COPYTO_ITEM;
		errorMessage = L"Failed to set the CC Recipients of notes message";
		break;
	case AbstractRecipient::BLINDCOPYTO:
		notesRecipientField = MAIL_BLINDCOPYTO_ITEM;
		errorMessage = L"Failed to set the BCC Recipients of notes message";
		break;
	default:
		return;
	}

	vector_wstring recipientsVector = Parser::ExtractRecipientsItems(recipients);
	if(recipientsVector.empty())
		return;

	STATUS status = NSFItemSetText(noteHandle, notesRecipientField.c_str(), "", 0);
	if(LNNOERROR != status)
	{
		LOG_WS_ERROR(L"Failed to clear the recipient field. Continue to append items");
	}

    for(vector_wstring::size_type index = 0; index < recipientsVector.size(); ++index)
	{
        std::string recipient = Workshare::Conversions::W22LMBCS(recipientsVector[index].c_str());
		status = NSFItemAppendTextList(noteHandle, notesRecipientField.c_str(), recipient.c_str(), (WORD)recipient.size(), FALSE);
		if(LNNOERROR != status)
        {
			std::wostringstream msg;
            msg << L"Failed to append [" << recipientsVector[index].c_str() << L"] " << L"to the recipient list [" <<  Workshare::Conversions::A22W(notesRecipientField.c_str()).c_str() << L"]" << std::ends;
            LOG_WS_ERROR(msg.str().c_str());
        }
		else
		{
			std::wostringstream msg;
            msg << L"Append [" << recipientsVector[index].c_str() << L"] " << L"to the recipient list [" <<  Workshare::Conversions::A22W(notesRecipientField.c_str()).c_str() << L"]" << std::ends;
            LOG_WS_ERROR(msg.str().c_str());
		}
	}
}
/** 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(