diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-06-26 08:18:23 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-06-26 08:18:23 +0800 |
commit | 3570cc5bbf3c5d3b10d578a0f8444d95e57eb4d3 (patch) | |
tree | 9ca85931cb4c9f5847a06daa68b4154a3c477e52 | |
parent | b44b57aa7e6be672c60b095e65525ed42d6cc94a (diff) | |
download | gsoc2013-evolution-3570cc5bbf3c5d3b10d578a0f8444d95e57eb4d3.tar.gz gsoc2013-evolution-3570cc5bbf3c5d3b10d578a0f8444d95e57eb4d3.tar.zst gsoc2013-evolution-3570cc5bbf3c5d3b10d578a0f8444d95e57eb4d3.zip |
g_strdup() the message source here or we will have problems later when we
2001-06-25 Jeffrey Stedfast <fejj@ximian.com>
* camel-filter-search.c (get_source): g_strdup() the message
source here or we will have problems later when we go to free the
result ;-)
svn path=/trunk/; revision=10498
-rw-r--r-- | camel/ChangeLog | 6 | ||||
-rw-r--r-- | camel/camel-filter-driver.c | 37 | ||||
-rw-r--r-- | camel/camel-filter-search.c | 61 | ||||
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 4 |
4 files changed, 58 insertions, 50 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 60b0acf30c..4b312693d0 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,9 @@ +2001-06-25 Jeffrey Stedfast <fejj@ximian.com> + + * camel-filter-search.c (get_source): g_strdup() the message + source here or we will have problems later when we go to free the + result ;-) + 2001-06-25 Dan Winship <danw@ximian.com> * providers/imap/camel-imap-store.c (try_auth): Fix this: IMAP diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c index 4284af1f8e..c998577395 100644 --- a/camel/camel-filter-driver.c +++ b/camel/camel-filter-driver.c @@ -757,7 +757,7 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde for (i = 0; i < uids->len; i++) { int pc = (100 * i)/uids->len; - + report_status (driver, CAMEL_FILTER_STATUS_START, pc, _("Getting message %d of %d"), i+1, uids->len); @@ -779,7 +779,7 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde if (camel_folder_has_summary_capability (folder)) camel_folder_free_message_info (folder, info); - + if (camel_exception_is_set (ex) || status == -1) { report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed at message %d of %d"), i+1, uids->len); @@ -789,19 +789,20 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde if (remove) camel_folder_set_message_flags (folder, uids->pdata[i], - CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN); + CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN, + CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN); camel_object_unref (CAMEL_OBJECT (message)); } - + if (freeuids) camel_folder_free_uids (folder, uids); if (p->defaultfolder) { - report_status(driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder")); + report_status (driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder")); camel_folder_sync (p->defaultfolder, FALSE, ex); } - + if (i == uids->len) report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Complete")); @@ -844,7 +845,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage struct _filter_rule *node; gboolean freeinfo = FALSE; gboolean filtered = FALSE; - + if (info == NULL) { struct _header_raw *h = CAMEL_MIME_PART (message)->headers; @@ -863,41 +864,44 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage p->info = info; p->uid = uid; p->source = source; - + if (original_source_url && camel_mime_message_get_source (message) == NULL) camel_mime_message_set_source (message, original_source_url); node = (struct _filter_rule *)p->rules.head; while (node->next) { - d(fprintf (stderr, "applying rule %s\n action %s\n", node->match, node->action)); + d(fprintf (stderr, "applying rule %s\naction %s\n", node->match, node->action)); - if (camel_filter_search_match(p->message, p->info, - original_source_url ? original_source_url : source_url, - node->match, p->ex)) { + if (camel_filter_search_match (p->message, p->info, + original_source_url ? original_source_url : source_url, + node->match, p->ex)) { filtered = TRUE; camel_filter_driver_log (driver, FILTER_LOG_START, node->name); /* perform necessary filtering actions */ e_sexp_input_text (p->eval, node->action, strlen (node->action)); if (e_sexp_parse (p->eval) == -1) { - camel_exception_setv(ex, 1, _("Error parsing filter: %s: %s"), e_sexp_error(p->eval), node->action); + camel_exception_setv (ex, 1, _("Error parsing filter: %s: %s"), + e_sexp_error (p->eval), node->action); goto error; } r = e_sexp_eval (p->eval); if (r == NULL) { - camel_exception_setv(ex, 1, _("Error executing filter: %s: %s"), e_sexp_error(p->eval), node->action); + camel_exception_setv (ex, 1, _("Error executing filter: %s: %s"), + e_sexp_error (p->eval), node->action); goto error; } e_sexp_result_free (p->eval, r); if (p->terminated) break; } + node = node->next; } /* *Now* we can set the DELETED flag... */ if (p->deleted) - info->flags = info->flags | CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_FOLDER_FLAGGED | CAMEL_MESSAGE_SEEN; + info->flags = info->flags | CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_FOLDER_FLAGGED; /* Logic: if !Moved and there exists a default folder... */ if (!(p->copied && p->deleted) && p->defaultfolder) { @@ -906,7 +910,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Copy to default folder"); if (p->uid && p->source && camel_folder_has_summary_capability (p->source)) { GPtrArray *uids; - + uids = g_ptr_array_new (); g_ptr_array_add (uids, (char *) p->uid); camel_folder_copy_messages_to (p->source, uids, p->defaultfolder, p->ex); @@ -917,6 +921,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage if (freeinfo) camel_message_info_free (info); + return 0; error: diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c index 05cc5eddc9..5396550d8f 100644 --- a/camel/camel-filter-search.c +++ b/camel/camel-filter-search.c @@ -108,7 +108,7 @@ check_header(struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa gboolean matched = FALSE; ESExpResult *r; int i; - + if (argc > 1 && argv[0]->type == ESEXP_RES_STRING) { char *name = argv[0]->value.string; const char *header; @@ -234,7 +234,7 @@ header_full_regex (struct _ESExp *f, int argc, struct _ESExpResult **argv, Filte ESExpResult *r = e_sexp_result_new(f, ESEXP_RES_BOOL); regex_t pattern; char *contents; - + if (camel_search_build_match_regex(&pattern, CAMEL_SEARCH_MATCH_REGEX|CAMEL_SEARCH_MATCH_ICASE, argc-1, argv+1, fms->ex) == 0) { contents = get_full_header (fms->message); r->value.bool = regexec(&pattern, contents, 0, NULL, 0) == 0; @@ -253,11 +253,11 @@ match_all (struct _ESExp *f, int argc, struct _ESExpTerm **argv, FilterMessageSe ESExpResult *r; if (argc > 0) - return e_sexp_term_eval(f, argv[0]); - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); + return e_sexp_term_eval (f, argv[0]); + + r = e_sexp_result_new (f, ESEXP_RES_BOOL); r->value.bool = FALSE; - + return r; } @@ -307,7 +307,7 @@ user_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessage } } - r = e_sexp_result_new(f, ESEXP_RES_BOOL); + r = e_sexp_result_new (f, ESEXP_RES_BOOL); r->value.bool = truth; return r; @@ -322,7 +322,7 @@ system_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa if (argc == 1) truth = camel_system_flag_get (fms->info->flags, argv[0]->value.string); - r = e_sexp_result_new(f, ESEXP_RES_BOOL); + r = e_sexp_result_new (f, ESEXP_RES_BOOL); r->value.bool = truth; return r; @@ -336,7 +336,7 @@ user_tag (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageS tag = camel_tag_get (&fms->info->user_tags, argv[0]->value.string); - r = e_sexp_result_new(f, ESEXP_RES_STRING); + r = e_sexp_result_new (f, ESEXP_RES_STRING); r->value.string = g_strdup (tag ? tag : ""); return r; @@ -347,8 +347,8 @@ get_sent_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMes { ESExpResult *r; - r = e_sexp_result_new(f, ESEXP_RES_INT); - r->value.number = camel_mime_message_get_date(fms->message, NULL); + r = e_sexp_result_new (f, ESEXP_RES_INT); + r->value.number = camel_mime_message_get_date (fms->message, NULL); return r; } @@ -358,8 +358,8 @@ get_received_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, Filte { ESExpResult *r; - r = e_sexp_result_new(f, ESEXP_RES_INT); - r->value.number = camel_mime_message_get_date_received(fms->message, NULL); + r = e_sexp_result_new (f, ESEXP_RES_INT); + r->value.number = camel_mime_message_get_date_received (fms->message, NULL); return r; } @@ -369,7 +369,7 @@ get_current_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, Filter { ESExpResult *r; - r = e_sexp_result_new(f, ESEXP_RES_INT); + r = e_sexp_result_new (f, ESEXP_RES_INT); r->value.number = time (NULL); return r; @@ -383,7 +383,7 @@ get_score (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessage tag = camel_tag_get (&fms->info->user_tags, "score"); - r = e_sexp_result_new(f, ESEXP_RES_INT); + r = e_sexp_result_new (f, ESEXP_RES_INT); if (tag) r->value.number = atoi (tag); else @@ -397,21 +397,19 @@ get_source (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessag { ESExpResult *r; - r = e_sexp_result_new(f, ESEXP_RES_STRING); + r = e_sexp_result_new (f, ESEXP_RES_STRING); if (fms->source) { r->value.string = e_url_shroud (fms->source); } else { - r->value.string = camel_mime_message_get_source (fms->message); + r->value.string = g_strdup (camel_mime_message_get_source (fms->message)); } - - g_message ("got source: [%s]", r->value.string); return r; } gboolean -camel_filter_search_match(CamelMimeMessage *message, CamelMessageInfo *info, - const char *source, const char *expression, CamelException *ex) +camel_filter_search_match (CamelMimeMessage *message, CamelMessageInfo *info, + const char *source, const char *expression, CamelException *ex) { FilterMessageSearch fms; ESExp *sexp; @@ -435,31 +433,30 @@ camel_filter_search_match(CamelMimeMessage *message, CamelMessageInfo *info, e_sexp_input_text (sexp, expression, strlen (expression)); if (e_sexp_parse (sexp) == -1) { - if (!camel_exception_is_set(ex)) - camel_exception_setv(ex, 1, _("Error executing filter search: %s: %s"), e_sexp_error(sexp), expression); + if (!camel_exception_is_set (ex)) + camel_exception_setv (ex, 1, _("Error executing filter search: %s: %s"), + e_sexp_error (sexp), expression); goto error; } result = e_sexp_eval (sexp); if (result == NULL) { - if (!camel_exception_is_set(ex)) - camel_exception_setv(ex, 1, _("Error executing filter search: %s: %s"), e_sexp_error(sexp), expression); + if (!camel_exception_is_set (ex)) + camel_exception_setv (ex, 1, _("Error executing filter search: %s: %s"), + e_sexp_error (sexp), expression); goto error; } - + if (result->type == ESEXP_RES_BOOL) retval = result->value.bool; else retval = FALSE; e_sexp_result_free (sexp, result); - e_sexp_unref(sexp); + e_sexp_unref (sexp); return retval; - + error: - e_sexp_unref(sexp); + e_sexp_unref (sexp); return FALSE; } - - - diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index 30bb9d5c80..48b4250185 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -688,7 +688,7 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex) if (!respbuf || strncmp (respbuf, "250", 3)) { int error; - + error = respbuf ? atoi (respbuf) : 0; g_free (respbuf); camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, @@ -949,7 +949,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bi get_smtp_error_string (error)); return FALSE; } - + g_free (respbuf); respbuf = NULL; |