Logo Search packages:      
Sourcecode: pan version File versions  Download package

const Article * DataImpl::xover_add ( const Quark server,
const Quark group,
const StringView subject,
const StringView author,
const time_t  time,
const StringView message_id,
const StringView references,
const unsigned long  byte_count,
const unsigned long  line_count,
const StringView xref 
) [virtual]

A new header to add to a group. This must be called inside an xover_ref() / xover_unref() block.

If a new article was created -- as opposed to a new part being added to an existing article -- then a pointer to the new article is returned.

FIXME: this return value is kind of odd, and is just there to suit task-xover's needs.

Add the article's part info

Implements pan::Data.

Definition at line 226 of file xover.cc.

References pan::DataImpl::XOverEntry::_added_batch, pan::DataImpl::XOverEntry::_changed_batch, pan::DataImpl::XOverEntry::_subject_lookup, load_article(), load_part(), xover_flush(), and xover_get_workarea().

  GroupHeaders * h (get_group_headers (group));
  if (!h) {
    Log::add_err_va (_("Error reading from %s: unknown group \"%s\""),
    return 0;

  const Article* new_article (0);
  h->_dirty = true;
  XOverEntry& workarea (xover_get_workarea (group));
  const std::string references (
    GNKSA :: remove_broken_message_ids_from_references (references_in));

  **** Multipart Handling

  int part_index, part_count;
  std::string multipart_subject;
  find_parts (subject, group, line_count, part_index, part_count, multipart_subject);
  const Quark multipart_subject_quark (multipart_subject);
  Quark art_mid;

  if (part_count > 1)
    // walk through the articles we've already got for the group
    // to see if there's already an Article allocated to this
    // multipart.  If there is, we use it here instead of adding a new one

    typedef XOverEntry::subject_to_mid_t::const_iterator cit;
    const std::pair<cit,cit> range (workarea._subject_lookup.equal_range (multipart_subject_quark));
    for (cit it(range.first), end(range.second); it!=end && art_mid.empty(); ++it) {
      const Quark& candidate_mid (it->second);
      const Article* candidate (h->find_article (candidate_mid));
      if (candidate
          && (candidate->author == author)
          && ((int)candidate->get_total_part_count() == part_count))
        art_mid = candidate_mid;

  if (art_mid.empty())
    art_mid = message_id;

    if (part_count > 1)
      workarea._subject_lookup.insert(std::pair<Quark,Quark>(multipart_subject_quark, art_mid));

    // if we don't already have this article...
    if (!h->find_article (art_mid))
      //std::cerr << LINE_ID << " We didn't have this article yet, so creating an instance..." << std::endl;
      Article& a (h->alloc_new_article());
      a.author = author;
      a.subject = multipart_subject_quark;
      a.message_id = art_mid;
      a.is_binary = part_count >= 1;
      a.set_part_count (a.is_binary ? part_count : 1);
      a.time_posted = time_posted;
      a.xref.insert (server, xref);
      load_article (group, &a, references);
      new_article = &a;

      workarea._added_batch.insert (art_mid);

  ***  Add the article's part info

    const int number (part_count<2 ? 1 : part_index);
    load_part (group, art_mid,
               number, message_id,
               line_count, byte_count);

  if (!workarea._added_batch.count(art_mid))

  // maybe flush the batched changes
  if ((time(0) - workarea._last_flush_time) >= 10)
    xover_flush (group);

  return new_article;

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index