Class Injector.

Inherits EventHandler

Stores message objects in the database.

This class takes a list of Message objects and performs the database operations necessary to inject them into their respective mailboxes. Injection commences only when execute() is called.

Injector::Injector( EventHandler * owner )

Creates a new Injector to inject messages into the database on behalf of the owner, which is notified when the injection is completed.

void Injector::addAddress( Address * a )

Ensures that a is present in the database after injection.

uint Injector::addAnnotations( Query * q, Injectee * m, Mailbox * mb )

Adds annotations rows for the message m in mailbox mb to the query q, and returns the number of annotations (may be 0).

void Injector::addBodypartRow( Bodypart * b )

Adds b to the list of bodyparts if it's not there already.

void Injector::addDelivery( Injectee * message, Address * sender, List<Address> * recipients, Date * later )

Notes that message must be injected, and spooled for delivery to the specified recipients from the given sender, and delivered later if later is non-null.

uint Injector::addFlags( Query * q, Injectee * m, Mailbox * mb )

Adds flags rows for the message m in mailbox mb to the query q, and returns the number of flags (which may be 0).

void Injector::addHeader( Query * qh, Query * qa, Query * qd, uint mid, const EString & part, Header * h )

Add each field from the header h (belonging to the given part of the message with id mid) to one of the queries qh, qa, or qd, depending on their type.

void Injector::addInjection( List<Injectee> * messages )

Notes that messages must be injected into the database.

void Injector::addMailbox( Query * q, Injectee * m, Mailbox * mb )

Adds a mailbox_messages row for the message m in mailbox mb to the query q.

void Injector::addMoreReferences()

Like convertInReplyTo(), except that it looks at other messages being injected rather than messages already in the database.

This is a no-op when messages are inserted using SMTP or LMTP, but can matter for aoximport.

void Injector::addPartNumber( Query * q, uint mid, const EString & part, Bodypart * b )

Adds a single part_numbers row for the given part number, belonging to the message with id mid and the bodypart b (which may be 0) to the query q.

uint Injector::addressId( Address * a )

Returns the database ID of a, or 0 if this injector hasn't added a to the database.

void Injector::cache()

Inserts this/these message/s into the MessageCache. If the transaction fails, the cache has to be cleared.

void Injector::convertInReplyTo()

Creates a proper References field for any messages which have In-Reply-To but not References. This covers some versions of Outlook, but not all.

void Injector::convertThreadIndex()

Creates a proper References field for any messages sent by Outlook*, ie. having Thread-Index instead of References.

void Injector::createDependencies()

This function creates any unknown names found by findDependencies(). It creates up to four subtransactions and advances to the next state, trusting Transaction to queue the work appropriately.

void Injector::createMailboxes()

This private function looks through the list of messages, notes what mailboxes are needed, and creates any that do not exist or are currently deleted.

bool Injector::done() const

Returns true if this injector has finished its work, and false if it hasn't started or is currently working.

EString Injector::error() const

Returns an error message if injection failed, or an empty string if it succeeded or hasn't failed yet.

bool Injector::failed() const

Returns true if this injection failed, and false if it has succeeded or is in progress.

void Injector::findDependencies()

This private function looks through the list of messages given to this Injector, to make sure that they are all valid, and to collect lists of any unknown header field names, flags, annotation names, or addresses.

In the common case there will be few, if any, entries to insert into the *_names tables, so we build lists of them without worrying about memory use. The list of addresses may be large, but we can't avoid building that list anyway.

void Injector::findMessages()

This private helper makes a master list of messages to be inserted, based on what addDelivery() and addInjection() have done.

void Injector::insertBodyparts()

Inserts all unique bodyparts in the messages into the bodyparts table, and updates the in-memory objects with the newly-created bodyparts.ids.

void Injector::insertDeliveries()

This private function inserts one row per remote recipient into the deliveries table.

void Injector::insertMessages()

Injects messages into the correct tables.

void Injector::insertThreadIndexes()

Inserts rows into the thread_indexes table, so that convertThreadIndex() will have fodder next time it runs.

void Injector::insertThreadRoots()

Inserts rows into the thread_rows table and records to which thread_rows row each Injectee belong.

uint Injector::internalDate( Message * m ) const

Returns a sensible internaldate for m. If Message::internalDate() is not null, it is used, otherwise this function tries to obtain a date heuristically.

void Injector::logDescription()

Logs a little information about the messages to be injected, and a little more for the special case of a single message being injected into a single mailbox.

void Injector::next()

This private function advances the injector to the next state.

void Injector::selectMessageIds()

This function inserts rows into the messages table for each Message in d->messages, and updates the objects with the newly-created ids. It expects to be called repeatedly until it returns true, which it does only when the work is done, or an error occurs.

Query * Injector::selectNextvals( const EString & sequence, uint num )

Returns a new Query to select num nextval()s as "id" from the named sequence.

void Injector::selectUids()

This private function is responsible for fetching a uid and modseq value for each message in each mailbox and incrementing uidnext and nextmodseq appropriately.

void Injector::setTransaction( Transaction * t )

Instructs this Injector to use a subtransaction of t for all its database work.

Does nothing if the injector already has a transaction.

void Injector::updateAddresses( List<Address> * newAddresses )

Adds previously unknown addresses from newAddresses to d->addresses.

This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.