void CClientMimeHandler::begin(const Item& aMimeItem) { Iterator_t lChildIter; //initialize ENVELOPE theEnvelope = mail_newenvelope (); //initialize BODY theBody = mail_newbody (); mail_initbody(theBody); //set theMessageItem lChildIter = aMimeItem.getChildren(); lChildIter->open(); // read envelope and body elements but skip non-element nodes while (lChildIter->next(theEnvelopeItem)) { if (theEnvelopeItem.getNodeKind() == store::StoreConsts::elementNode) { break; } } while (lChildIter->next(theBodyItem)) { if (theBodyItem.getNodeKind() == store::StoreConsts::elementNode) { break; } } lChildIter->close(); }
ENVELOPE *create_imap_envelope( FeriteScript *script, FeriteVariable *header ){ ENVELOPE *env = mail_newenvelope(); FeriteVariable *v; ADDRESS *a; int i; v = ferite_hash_get( script, VAO(header)->variables->variables, "to" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find to address"); a = create_imap_address( script, v ); if(a) env->to = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "from" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find from address"); a = create_imap_address( script, v ); if(a) env->from = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "cc" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find cc address"); a = create_imap_address( script, v ); if(a) env->cc = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "bcc" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find bcc address"); a = create_imap_address( script, v ); if(a) env->bcc = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "return_path" ); if(v) { a = create_imap_address( script, v ); if(a) env->return_path = a; } if(env->return_path == NULL) { v = ferite_hash_get( script, VAO(header)->variables->variables, "from" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find create return path"); a = create_imap_address( script, v ); if(a) env->return_path = a; } v = ferite_hash_get( script, VAO(header)->variables->variables, "sender" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find sender"); a = create_imap_address( script, v ); if(a) env->sender = a; v = ferite_hash_get( script, VAO(header)->variables->variables, "subject" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find subject"); env->subject = cpystr( VAS(v)->data ); RETURN_IF_NULL( env->subject ); v = ferite_hash_get( script, VAO(header)->variables->variables, "in_reply_to" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find in reply to header"); env->in_reply_to = cpystr( VAS(v)->data ); RETURN_IF_NULL( env->in_reply_to ); v = ferite_hash_get( script, VAO(header)->variables->variables, "ID" ); ERROR_IF_NULL(v, script, "Unable to create imap envelope - unable to find proposed message id"); env->message_id = cpystr( VAS(v)->data ); return env; }