Revert "Remove plaintext_file member of struct MsgInfo."
[claws.git] / src / plugins / perl / perl_plugin.c
index 0c3459060a77be0ef8565b68befa0ca2c917d9ef..6db4c412ddae78f07aa2570f95871cfb158c7ed1 100644 (file)
@@ -248,13 +248,13 @@ static gboolean update_PerlPluginTimedSList(PerlPluginTimedSList *tl)
 {
   gboolean retVal;
   gchar *indexfile;
-  struct stat filestat;
+  GStatBuf filestat;
 
   if(tl->g_slist == NULL)
     return TRUE;
 
   indexfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ADDRESSBOOK_INDEX_FILE, NULL);
-  if((stat(indexfile,&filestat) == 0) && filestat.st_mtime <= tl->mtime)
+  if((g_stat(indexfile,&filestat) == 0) && filestat.st_mtime <= tl->mtime)
      retVal = FALSE;
   else
     retVal = TRUE;
@@ -267,7 +267,7 @@ static gboolean update_PerlPluginTimedSList(PerlPluginTimedSList *tl)
 static void init_email_slist(void)
 {
   gchar *indexfile;
-  struct stat filestat;
+  GStatBuf filestat;
 
   if(email_slist->g_slist != NULL) {
     free_PerlPluginEmailEntry_slist(email_slist->g_slist);
@@ -277,7 +277,7 @@ static void init_email_slist(void)
   addrindex_load_person_attribute(NULL,add_to_email_slist);
 
   indexfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ADDRESSBOOK_INDEX_FILE, NULL);
-  if(stat(indexfile,&filestat) == 0)
+  if(g_stat(indexfile,&filestat) == 0)
     email_slist->mtime = filestat.st_mtime;
   g_free(indexfile);
   debug_print("Initialisation of email slist completed\n");
@@ -424,7 +424,7 @@ static void insert_attribute_hash(gchar *attr)
 {
   PerlPluginTimedSList *tl;
   gchar *indexfile;
-  struct stat filestat;
+  GStatBuf filestat;
 
   /* Check if key exists. Free it if it does. */
   if((tl = g_hash_table_lookup(attribute_hash,attr)) != NULL) {
@@ -445,7 +445,7 @@ static void insert_attribute_hash(gchar *attr)
   addrindex_load_person_attribute(attribute_key,add_to_attribute_hash);
 
   indexfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ADDRESSBOOK_INDEX_FILE, NULL);
-  if(stat(indexfile,&filestat) == 0)
+  if(g_stat(indexfile,&filestat) == 0)
     tl->mtime = filestat.st_mtime;
   g_free(indexfile);
 
@@ -559,6 +559,7 @@ static XS(XS_ClawsMail_filter_init)
   gchar buf[BUFFSIZE];
   GSList *walk;
   int ii;
+  gchar *xface;
 
   dXSARGS;
   if(items != 1) {
@@ -590,8 +591,8 @@ static XS(XS_ClawsMail_filter_init)
   case 10:
     msginfo->xref       ? XSRETURN_PV(msginfo->xref)       : XSRETURN_UNDEF;
   case 11:
-    (msginfo->extradata && msginfo->extradata->xface) ?
-      XSRETURN_PV(msginfo->extradata->xface)               : XSRETURN_UNDEF;
+    xface = procmsg_msginfo_get_avatar(msginfo, AVATAR_XFACE);
+    xface               ? XSRETURN_PV(xface)               : XSRETURN_UNDEF;
   case 12:
     (msginfo->extradata && msginfo->extradata->dispositionnotificationto) ?
       XSRETURN_PV(msginfo->extradata->dispositionnotificationto) : XSRETURN_UNDEF;
@@ -990,7 +991,6 @@ static XS(XS_ClawsMail_clear_tags)
 static XS(XS_ClawsMail_make_sure_tag_exists)
 {
   gchar *tag_str;
-  gint tag_id;
 
   dXSARGS;
   if(items != 1) {
@@ -1708,7 +1708,7 @@ static int perl_init(void)
 "     qw(forwarded locked colorlabel match matchcase),\n"
 "     qw(regexp regexpcase test),\n"
 "     qw(to cc subject from to_or_cc newsgroups inreplyto),\n"
-"     qw(references body_part headers_part message),\n"
+"     qw(references body_part headers_part headers_cont message),\n"
 "     qw(size_greater size_smaller size_equal),\n"
 "     qw(score_greater score_lower score_equal),\n"
 "     qw(age_greater age_lower partial tagged $permanent));\n"
@@ -1737,6 +1737,7 @@ static int perl_init(void)
 "sub references   { return \"references\";    }\n"
 "sub body_part    { return \"body_part\";     }\n"
 "sub headers_part { return \"headers_part\";  }\n"
+"sub headers_cont { return \"headers_cont\";  }\n"
 "sub message      { return \"message\";       }\n"
 "# access the mail directly\n"
 "sub header {\n"
@@ -1994,6 +1995,16 @@ static int perl_init(void)
 "      return ($myheader =~ m/$what/) unless $nocase;\n"
 "      return ($myheader =~ m/$what/i);\n"
 "    }\n"
+"  } elsif($where eq \"headers_cont\") {\n"
+"    (my $myheader = header_as_string_()) =~ s{^\\S+:\\s*}{};\n"
+"    if(not $regexp) {\n"
+"      $myheader =~ s/\\s+/ /g;\n"
+"      return (index($myheader,$what) != -1) unless $nocase;\n"
+"      return (index(lc2_($myheader),lc2_($what)) != -1);\n"
+"    } else {\n"
+"      return ($myheader =~ m/$what/) unless $nocase;\n"
+"      return ($myheader =~ m/$what/i);\n"
+"    }\n"
 "  } elsif($where eq \"message\") {\n"
 "    my $message = header_as_string_();\n"
 "    $message .= \"\\n\".body();\n"