~ubuntu-branches/ubuntu/intrepid/lurker/intrepid

« back to all changes in this revision

Viewing changes to index/Index.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Meurer
  • Date: 2006-12-20 05:05:31 UTC
  • mfrom: (3.1.6 feisty)
  • Revision ID: james.westby@ubuntu.com-20061220050531-79inzy7o6uu95qx7
Tags: 2.1-7
* updated vi debconf translations, thanks to Clytie Siddall
  <clytie@riverland.net.au>
* fixed typo in one template (that you would like, not that
  would you like), thanks as well to Clytie Siddall
  - unfuzzied all translations

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  $Id: Index.cpp,v 1.31 2004/08/27 17:53:44 terpstra Exp $
 
1
/*  $Id: Index.cpp,v 1.35 2006/02/24 13:17:29 terpstra Exp $
2
2
 *  
3
3
 *  index.cpp - Insert all the keywords from the given email
4
4
 *  
22
22
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
23
 */
24
24
 
25
 
#define _XOPEN_SOURCE 500
26
25
#define _FILE_OFFSET_BITS 64
27
26
 
28
27
#include <mimelib/headers.h>
233
232
        return i->writer->insert(x);
234
233
}
235
234
 
236
 
int Index::index_id(bool userdate, time_t server)
 
235
int Index::index_id(bool userdate, time_t server, bool& exist)
237
236
{
238
237
        time_t stamp = server;
239
238
        string messageId;
289
288
        }
290
289
        
291
290
        id = MessageId(stamp, hash);
 
291
        if (blacklist.find(id) != blacklist.end())
 
292
        {
 
293
                // Messages marked as blacklisted use the 'exist' flag to
 
294
                // avoid being imported into the database.
 
295
                exist = true;
 
296
                return 0;
 
297
        }
292
298
        
293
 
        if (messageId.length() && writer->insert(
294
 
                LU_KEYWORD +
295
 
                string(LU_KEYWORD_MESSAGE_ID) +
296
 
                messageId +
297
 
                '\0' + 
298
 
                id.raw()) != 0)
 
299
        if (messageId.length())
299
300
        {
300
 
                cerr << "Failed to insert message id keyword!" << endl;
301
 
                return -1;
 
301
                // Raw message-id for threading
 
302
                if (writer->insert(
 
303
                        LU_KEYWORD +
 
304
                        string(LU_KEYWORD_MESSAGE_ID) +
 
305
                        messageId +
 
306
                        '\0' + 
 
307
                        id.raw()) != 0)
 
308
                {
 
309
                        cerr << "Failed to insert message id keyword!" << endl;
 
310
                        return -1;
 
311
                }
 
312
                
 
313
                // digested message-id for user searches
 
314
                if (my_keyword_digest_string(
 
315
                        messageId.c_str(), messageId.length(),
 
316
                        LU_KEYWORD_MESSAGE_ID, &feed_writer, this, 0) != 0)
 
317
                {
 
318
                        cerr << "Failed to index message-id" << endl;
 
319
                        return -1;
 
320
                }
302
321
        }
303
322
        
304
323
        if (writer->insert(
463
482
        
464
483
        /* emulated group and language searches are impossibly slow.
465
484
         * these keywords are a must for large archives.
466
 
         * see the regroupable option in the stock lurker.conf
467
485
         */
468
486
        if (writer->insert(
469
487
                LU_KEYWORD
472
490
                '\0' +
473
491
                id.raw()) != 0) ok = false;
474
492
        
475
 
        if (writer->insert(
476
 
                LU_KEYWORD
477
 
                LU_KEYWORD_LANGUAGE +
478
 
                list.language +
479
 
                '\0' +
480
 
                id.raw()) != 0) ok = false;
 
493
        set<string>::const_iterator i, e;
 
494
        for (i = list.languages.begin(), e = list.languages.end(); i != e; ++i)
 
495
                if (writer->insert(
 
496
                        LU_KEYWORD
 
497
                        LU_KEYWORD_LANGUAGE +
 
498
                        *i +
 
499
                        '\0' +
 
500
                        id.raw()) != 0) ok = false;
481
501
        
482
502
        MessageId importStamp(import);
483
503
        if (writer->insert(
643
663
//      cout << message.Headers().Subject().AsString().c_str() << endl;
644
664
        
645
665
        if (index_author() < 0) return -1;
646
 
        if (index_id(userdate, envelope) < 0) return -1;
 
666
        
 
667
        /* If the message is blacklisted, we mark it as 'existing' */
 
668
        if (index_id(userdate, envelope, exist) < 0) return -1;
 
669
        if (exist) return 0;
 
670
        
 
671
        /* If the message is already imported, mark it as 'existing' */
647
672
        if (index_summary(check, exist) < 0) return -1;
648
 
        
649
673
        if (exist) return 0;
650
674
        
651
675
        if (index_threading(      )                < 0) return -1;