void collect(char *file) { struct mailinfo *m; struct mlist *ml; if ((m = mailfile(file)) == 0) return; if (m->depth == 0) { if (thr) do_thr(); /* new thread */ thr = calloc(1, sizeof *thr); if (!thr) { fprintf(stderr, "calloc"); exit(2); } thr->matched = 0; ml = thr->cur = thr->childs; thr->cur->m = m; } else { ml = thr->cur + 1; if (thr->cur->m->depth < m->depth) { /* previous mail is a parent */ thr->cur->m->flags |= FLAG_PARENT; ml->parent = thr->cur; } else if (thr->cur->m->depth == m->depth) { /* same depth == same parent */ ml->parent = thr->cur->parent; } else if (thr->cur->m->depth > m->depth) { /* find parent mail */ struct mlist *pl; for (pl = thr->cur; pl->m->depth >= m->depth; pl--) ; ml->parent = pl; } m->flags |= FLAG_CHILD; thr->cur->next = ml; thr->cur = ml; ml->m = m; } for (ml = ml->parent; ml; ml = ml->parent) ml->m->replies++; m->fpath = strdup(m->fpath); }
void oneline(char *file) { struct mailinfo *m; m = mailfile(file); if (expr && !eval(expr, m)) goto out; fputs(file, stdout); putchar('\n'); kept++; out: if (m->msg) blaze822_free(m->msg); if (m->sb) free(m->sb); free(m); }
void p3Fido::sendMail( const char * filename ) { std::ifstream mailfile( filename, std::ifstream::in ); if( !mailfile.good() ){ std::cerr << "Fido: Cannot open mail file " << filename << std::endl; return; } MessageInfo mi; mimetic::MimeEntity me( mailfile ); std::string msgId = me.header().messageid().str(); std::map< std::string, int >::iterator msgIt = m_sentMsgs.find( msgId ); if( msgIt != m_sentMsgs.end() ){ // we had this message already (*msgIt).second--; if( (*msgIt).second == 1 ){ m_sentMsgs.erase( msgIt ); } return; } std::list< std::string > unknownMailboxes; int numAddr = 0; mimetic::AddressList & toList = me.header().to(); for( mimetic::AddressList::const_iterator it = toList.begin(); it != toList.end(); it++ ){ mimetic::Mailbox mailbox = (*it).mailbox(); if( mailbox.domain() != MAILDOMAIN ) continue; numAddr++; std::string rsAddr = mailbox.mailbox(); RsGxsId gxsid( rsAddr ); RsIdentityDetails detail; if(!rsIdentity->getIdDetails(gxsid, detail)){ mi.rsgxsid_msgto.push_back( RsGxsId( gxsid ) ); } else{ unknownMailboxes.push_back( mailbox.str() ); } } mimetic::AddressList & ccList = me.header().cc(); for( mimetic::AddressList::const_iterator it = ccList.begin(); it != ccList.end(); it++ ){ mimetic::Mailbox mailbox = (*it).mailbox(); if( mailbox.domain() != MAILDOMAIN ) continue; numAddr++; std::string rsAddr = mailbox.mailbox(); RsGxsId gxsid( rsAddr ); RsIdentityDetails detail; if(!rsIdentity->getIdDetails(gxsid, detail)){ mi.rsgxsid_msgcc.push_back( gxsid ); } else{ unknownMailboxes.push_back( mailbox.str() ); } } m_sentMsgs[ msgId ] = numAddr; mi.title = me.header().subject(); std::string bodyText; mimetic::ContentType contentType = me.header().contentType(); if( contentType.type() == "text" && contentType.subtype() == "plain" ){ bodyText = me.body().data(); } else{ mimetic::MimeEntityList& parts = me.body().parts(); mimetic::MimeEntityList::iterator mbit = parts.begin(); if( mbit != parts.end() ){ mimetic::MimeEntity * pme = *mbit; bodyText = pme->body().data(); } } mi.msg = bodyText; RsGxsId mygxsid( MY_GXSID ); mi.rsgxsid_srcId = mygxsid; mi.msgflags = 0; mi.msgId = msgId; if( !mi.rsgxsid_msgcc.empty() || !mi.rsgxsid_msgto.empty() ){ rsMsgs->MessageSend(mi); } if( !unknownMailboxes.empty() ) bounceMail( unknownMailboxes, mi ); }