@@ -724,41 +724,40 @@ DbmailMessage * dbmail_message_init_with_string(DbmailMessage *self, const GStri
724
724
GMimeStream * stream ;
725
725
726
726
assert (self -> content == NULL );
727
+ assert (self -> raw_content == NULL );
727
728
728
729
stream = g_mime_stream_mem_new_with_buffer (str -> str , str -> len );
729
730
parser = g_mime_parser_new_with_stream (stream );
730
731
g_object_unref (stream );
731
732
732
- if (strncmp (str -> str , "From " , 5 ) == 0 ) {
733
- /* don't use gmime's from scanner since body lines may begin with 'From ' */
734
- char * end ;
735
- if ((end = g_strstr_len (str -> str , 80 , "\n" ))) {
736
- size_t l = end - str -> str ;
737
- from = g_strndup (str -> str , l );
738
- TRACE (TRACE_DEBUG , "From_ [%s]" , from );
739
- }
740
- }
741
-
742
733
content = GMIME_OBJECT (g_mime_parser_construct_message (parser ));
743
734
if (content ) {
744
735
dbmail_message_set_class (self , DBMAIL_MESSAGE );
745
- self -> content = content ;
746
- self -> raw_content = dbmail_message_to_string (self );
747
- if (from ) {
748
- dbmail_message_set_internal_date (self , from );
736
+
737
+ if (strncmp (str -> str , "From " , 5 ) == 0 ) {
738
+ /* don't use gmime's from scanner since body lines may begin with 'From ' */
739
+ char * end ;
740
+ if ((end = g_strstr_len (str -> str , 80 , "\n" ))) {
741
+ size_t l = end - str -> str ;
742
+ from = g_strndup (str -> str , l );
743
+ TRACE (TRACE_DEBUG , "From_ [%s]" , from );
744
+ dbmail_message_set_internal_date (self , from );
745
+ g_free (from );
746
+ }
749
747
}
750
- g_object_unref (parser );
748
+
749
+ self -> content = content ;
750
+ self -> raw_content = g_strdup (str -> str );
751
751
} else {
752
752
content = GMIME_OBJECT (g_mime_parser_construct_part (parser ));
753
753
if (content ) {
754
754
dbmail_message_set_class (self , DBMAIL_MESSAGE_PART );
755
755
self -> content = content ;
756
- self -> raw_content = dbmail_message_to_string (self );
757
- g_object_unref (parser );
756
+ self -> raw_content = g_strdup (str -> str );
758
757
}
759
758
}
759
+ g_object_unref (parser );
760
760
761
- if (from ) g_free (from );
762
761
_map_headers (self );
763
762
return self ;
764
763
}
@@ -815,15 +814,14 @@ static void _register_header(const char *header, const char *value, gpointer use
815
814
g_relation_insert (m -> headers , hname , hvalue );
816
815
}
817
816
818
- void dbmail_message_set_physid (DbmailMessage * self , uint64_t physid )
817
+ void dbmail_message_set_physid (DbmailMessage * self , uint64_t id )
819
818
{
820
- self -> id = physid ;
821
- self -> physid = physid ;
819
+ self -> id = id ;
822
820
}
823
821
824
822
uint64_t dbmail_message_get_physid (const DbmailMessage * self )
825
823
{
826
- return self -> physid ;
824
+ return self -> id ;
827
825
}
828
826
829
827
void dbmail_message_set_internal_date (DbmailMessage * self , char * internal_date )
@@ -1121,7 +1119,7 @@ static int _update_message(DbmailMessage *self)
1121
1119
uint64_t rfcsize = (uint64_t )dbmail_message_get_size (self ,TRUE);
1122
1120
1123
1121
if (! db_update ("UPDATE %sphysmessage SET messagesize = %lu, rfcsize = %lu WHERE id = %lu" ,
1124
- DBPFX , size , rfcsize , self -> physid ))
1122
+ DBPFX , size , rfcsize , self -> id ))
1125
1123
return DM_EQUERY ;
1126
1124
1127
1125
if (! db_update ("UPDATE %smessages SET status = %d WHERE message_idnr = %lu" ,
@@ -1336,7 +1334,7 @@ void _message_cache_envelope_date(const DbmailMessage *self)
1336
1334
_header_value_get_id (value , sortfield , datefield , & headervalue_id );
1337
1335
1338
1336
if (headervalue_id && headername_id )
1339
- _header_insert (self -> physid , headername_id , headervalue_id );
1337
+ _header_insert (self -> id , headername_id , headervalue_id );
1340
1338
1341
1339
g_free (value );
1342
1340
g_free (sortfield );
@@ -1346,7 +1344,7 @@ void _message_cache_envelope_date(const DbmailMessage *self)
1346
1344
int dbmail_message_cache_headers (const DbmailMessage * self )
1347
1345
{
1348
1346
assert (self );
1349
- assert (self -> physid );
1347
+ assert (self -> id );
1350
1348
1351
1349
if (! GMIME_IS_MESSAGE (self -> content )) {
1352
1350
TRACE (TRACE_ERR ,"self->content is not a message" );
@@ -1731,7 +1729,7 @@ static gboolean _header_cache(const char UNUSED *key, const char *header, gpoint
1731
1729
1732
1730
/* Insert relation between physmessage, header name and header value */
1733
1731
if (headervalue_id )
1734
- _header_insert (self -> physid , headername_id , headervalue_id );
1732
+ _header_insert (self -> id , headername_id , headervalue_id );
1735
1733
else
1736
1734
TRACE (TRACE_INFO , "error inserting headervalue. skipping." );
1737
1735
@@ -1747,7 +1745,7 @@ static gboolean _header_cache(const char UNUSED *key, const char *header, gpoint
1747
1745
return FALSE;
1748
1746
}
1749
1747
1750
- static void insert_field_cache (uint64_t physid , const char * field , const char * value )
1748
+ static void insert_field_cache (uint64_t id , const char * field , const char * value )
1751
1749
{
1752
1750
gchar * clean_value ;
1753
1751
C c ; S s ;
@@ -1761,7 +1759,7 @@ static void insert_field_cache(uint64_t physid, const char *field, const char *v
1761
1759
TRY
1762
1760
db_begin_transaction (c );
1763
1761
s = db_stmt_prepare (c ,"INSERT INTO %s%sfield (physmessage_id, %sfield) VALUES (?,?)" , DBPFX , field , field );
1764
- db_stmt_set_u64 (s , 1 , physid );
1762
+ db_stmt_set_u64 (s , 1 , id );
1765
1763
db_stmt_set_str (s , 2 , clean_value );
1766
1764
db_stmt_exec (s );
1767
1765
db_commit_transaction (c );
@@ -1796,7 +1794,7 @@ void dbmail_message_cache_referencesfield(const DbmailMessage *self)
1796
1794
g_free (field );
1797
1795
1798
1796
if (! refs ) {
1799
- TRACE (TRACE_DEBUG , "reference_decode failed [%lu]" , self -> physid );
1797
+ TRACE (TRACE_DEBUG , "reference_decode failed [%lu]" , self -> id );
1800
1798
return ;
1801
1799
}
1802
1800
@@ -1805,7 +1803,7 @@ void dbmail_message_cache_referencesfield(const DbmailMessage *self)
1805
1803
1806
1804
while (refs -> msgid ) {
1807
1805
if (! g_tree_lookup (tree ,refs -> msgid )) {
1808
- insert_field_cache (self -> physid , "references" , refs -> msgid );
1806
+ insert_field_cache (self -> id , "references" , refs -> msgid );
1809
1807
g_tree_insert (tree ,refs -> msgid ,refs -> msgid );
1810
1808
}
1811
1809
if (refs -> next == NULL )
@@ -1828,7 +1826,7 @@ void dbmail_message_cache_envelope(const DbmailMessage *self)
1828
1826
TRY
1829
1827
db_begin_transaction (c );
1830
1828
s = db_stmt_prepare (c , "INSERT INTO %senvelope (physmessage_id, envelope) VALUES (?,?)" , DBPFX );
1831
- db_stmt_set_u64 (s , 1 , self -> physid );
1829
+ db_stmt_set_u64 (s , 1 , self -> id );
1832
1830
db_stmt_set_str (s , 2 , envelope );
1833
1831
db_stmt_exec (s );
1834
1832
db_commit_transaction (c );
0 commit comments