Skip to content

Commit

Permalink
merging git tree
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.ic-s.nl/svn/dbmail/trunk/dbmail@2057 7b491191-dbf0-0310-aff6-d879d4d69008
  • Loading branch information
paul committed Apr 1, 2006
1 parent 1d18e55 commit d07b6ee
Show file tree
Hide file tree
Showing 21 changed files with 333 additions and 221 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2006-04-01 Paul J Stevens <paul@nfg.nl>

* sql/mysql/create_tables.mysql, sql/mysql/migrate_from_2.0_to_2.1.mysql:
cleanup mysql scripts
* debian/control, debian/dbmail.prerm, debian/rules:
fix some debian bugs
* check_dbmail_mailbox.c, dbmail-mailbox.c, dbmail-message.c,
dbmail-message.h, debian/control, mime.c, misc.c, modules/authsql.c,
modules/sortsieve.c, serverchild.c:
fix compiler warnings
* Makefile.am, check_dbmail_imapd.c, check_dbmail_message.c,
dbmail-message.c, dbmail-message.h, dbmail.h.in, debian/rules,
main.c, mime.c, mime.h:
removed mime.[ch]

2006-03-31 Paul J Stevens <paul@nfg.nl>

* db.c, modules/authsql.c:
Expand Down
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ COMMON = dbmail-user.c \
md5.c \
db.c \
misc.c \
mime.c \
pidfile.c

SERVER = server.c \
Expand Down
29 changes: 0 additions & 29 deletions check_dbmail_imapd.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,34 +297,6 @@ START_TEST(test_imap_bodyfetch)

}
END_TEST

//int find_deliver_to_header_addresses(struct DbmailMessage *self, char *scan_for_field,
// struct dm_list *targetlist)
//
START_TEST(test_find_deliver_to_header_addresses)
{
int result;
struct dm_list targetlist;
struct DbmailMessage *m;

m = dbmail_message_new();
m = dbmail_message_init_with_string(m,g_string_new(multipart_message));

dm_list_init(&targetlist);

result = find_deliver_to_header_addresses(m, "Cc", &targetlist);
struct element *el;
el = targetlist.start;

fail_unless(result==0, "find_deliver_to_header_addresses failed");
fail_unless(targetlist.total_nodes==2,"find_deliver_to_header_addresses failed");
fail_unless(strcmp((char *)el->data,"nobody@test123.com")==0, "find_deliver_to_header_addresses failed");

dbmail_message_free(m);
dm_list_free(&el);
}
END_TEST

START_TEST(test_g_mime_object_get_body)
{
char * result;
Expand Down Expand Up @@ -693,7 +665,6 @@ Suite *dbmail_suite(void)
tcase_add_test(tc_session, test_dbmail_imap_session_fetch_get_items);

tcase_add_checked_fixture(tc_mime, setup, teardown);
tcase_add_test(tc_mime, test_find_deliver_to_header_addresses);
tcase_add_test(tc_mime, test_g_mime_object_get_body);

tcase_add_checked_fixture(tc_util, setup, teardown);
Expand Down
31 changes: 17 additions & 14 deletions check_dbmail_mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ static int bodyfetch_parse_partspec(body_fetch_t *self, char **args, u64_t *idx)
(*idx)++; /* at first item of field list now, remember idx */
bodyfetch_set_argstart(self, *idx);

/* walk on untill list terminates (and it does 'cause parentheses are matched) */
/* walk on until list terminates (and it does 'cause parentheses are matched) */
while (! MATCH(args[*idx],")") )
(*idx)++;

Expand Down Expand Up @@ -540,13 +540,13 @@ static int _build_fetch(struct DbmailMailbox *self, char **args, u64_t *idx)
fetch_items_t *fi;

if (!args[*idx])
return -1; /* no more */
return 0; /* no more */

if (args[*idx][0] == '(')
(*idx)++;

if (!args[*idx])
return -2; /* error */
return -1; /* error */

fi = self->fi;

Expand Down Expand Up @@ -634,7 +634,7 @@ static int _build_fetch(struct DbmailMailbox *self, char **args, u64_t *idx)
if ((bodyfetch_parse_partspec(bodyfetch ,args, idx)) < 0) {
trace(TRACE_DEBUG,"%s,%s: bodyfetch_parse_partspec return with error",
__FILE__, __func__);
return -2;
return -1;
}
/* idx points to ']' now */
(*idx)++;
Expand All @@ -643,9 +643,9 @@ static int _build_fetch(struct DbmailMailbox *self, char **args, u64_t *idx)
} else {
if ((! nexttoken) && (strcmp(token,")") == 0)) {
/* only allowed if last arg here */
return -1;
return 0;
}
return -2; /* DONE */
return -1; /* unknown key */

}

Expand All @@ -663,27 +663,32 @@ static int dbmail_mailbox_fetch_build(struct DbmailMailbox *self, char **args)
fetchitems_free(self->fi);
self->fi = g_new0(fetch_items_t,1);

// _build_fetch(self,args, &idx);

while ((result = _build_fetch(self, args, &idx)) > 0)
;

return result;
}

static int dbmail_mailbox_fetch(struct DbmailMailbox *self)
{
fetch_items_t *fi = self->fi;

return 0;
}

START_TEST(test_dbmail_mailbox_fetch_build)
{
int i=0;
int i=0, result;
char **array;
const char *args;

struct DbmailMailbox *mb;
mb = dbmail_mailbox_new(get_mailbox_id());

while ((args = test_fetch_commands[i++])) {
printf("%s\n", args);
array = g_strsplit(args," ",0);
dbmail_mailbox_fetch_build(mb, array);
result = dbmail_mailbox_fetch_build(mb, array);
fail_unless(result==0,"dbmail_mailbox_fetch_build failed");
g_strfreev(array);
}

Expand All @@ -703,7 +708,7 @@ START_TEST(test_dbmail_mailbox_fetch)
args = test_fetch_commands[cmd++];
array = g_strsplit(args," ",0);
dbmail_mailbox_fetch_build(mb, array);
//dbmail_mailbox_fetch(mb);
dbmail_mailbox_fetch(mb);
g_strfreev(array);

array = g_strsplit(args," ",0);
Expand Down Expand Up @@ -984,9 +989,7 @@ Suite *dbmail_mailbox_suite(void)
tcase_add_test(tc_mailbox, test_dbmail_mailbox_orderedsubject);
*/
tcase_add_test(tc_mailbox, test_dbmail_mailbox_fetch_build);
/*
tcase_add_test(tc_mailbox, test_dbmail_mailbox_fetch);
*/
return s;
}

Expand Down
26 changes: 26 additions & 0 deletions check_dbmail_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,31 @@ START_TEST(test_dbmail_message_cache_headers)
}
END_TEST

START_TEST(test_dbmail_message_get_header_addresses)
{
int result;
struct dm_list targetlist;
struct DbmailMessage *m;

m = dbmail_message_new();
m = dbmail_message_init_with_string(m,g_string_new(multipart_message));

dm_list_init(&targetlist);

result = dbmail_message_get_header_addresses(m, "Cc", &targetlist);
struct element *el;
el = targetlist.start;

fail_unless(result==0, "dbmail_message_get_header_addresses failed");
fail_unless(targetlist.total_nodes==2,"dbmail_message_get_header_addresses failed");
fail_unless(strcmp((char *)el->data,"nobody@test123.com")==0, "dbmail_message_get_header_addresses failed");

dbmail_message_free(m);
dm_list_free(&el);
}
END_TEST


Suite *dbmail_message_suite(void)
{
Suite *s = suite_create("Dbmail Message");
Expand All @@ -390,6 +415,7 @@ Suite *dbmail_message_suite(void)
tcase_add_test(tc_message, test_dbmail_message_cache_headers);
tcase_add_test(tc_message, test_dbmail_message_free);
tcase_add_test(tc_message, test_dbmail_message_encoded);
tcase_add_test(tc_message, test_dbmail_message_get_header_addresses);
return s;
}

Expand Down
2 changes: 1 addition & 1 deletion dbmail-mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ static gboolean _do_sort(GNode *node, struct DbmailMailbox *self)
if (g_tree_lookup(self->ids,id))
self->sorted = g_list_prepend(self->sorted,id);
}
g_list_reverse(self->sorted);
self->sorted = g_list_reverse(self->sorted);
g_string_free(q,TRUE);
db_free_result();

Expand Down
45 changes: 44 additions & 1 deletion dbmail-message.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ gchar * dbmail_message_get_internal_date(const struct DbmailMessage *self)
return NULL;
}

void dbmail_message_set_envelope_recipient(struct DbmailMessage *self, char *envelope_recipient)
void dbmail_message_set_envelope_recipient(struct DbmailMessage *self, const char *envelope_recipient)
{
if (envelope_recipient)
g_string_printf(self->envelope_recipient,"%s", envelope_recipient);
Expand All @@ -418,6 +418,49 @@ const gchar * dbmail_message_get_header(const struct DbmailMessage *self, const
return g_mime_object_get_header(GMIME_OBJECT(self->content), header);
}

int dbmail_message_get_header_addresses(struct DbmailMessage *message,
const char *scan_for_field, struct dm_list *targetlist)
{
InternetAddressList *ialisthead, *ialist;
InternetAddress *ia;
const char *header_field;

if (!message || !scan_for_field || !targetlist) {
trace(TRACE_WARNING, "%s,%s: received a NULL argument, this is a bug",
__FILE__, __func__);
return -1;
}

header_field = dbmail_message_get_header(message, scan_for_field);
trace(TRACE_INFO, "%s,%s: mail address parser looking at field [%s] with value [%s]",
__FILE__, __func__, scan_for_field, header_field);

if ((ialist = internet_address_parse_string(header_field)) == NULL) {
trace(TRACE_ERROR, "%s,%s: mail address parser error parsing header field",
__FILE__, __func__);
return -1;
}

ialisthead = ialist;
while (1) {
ia = ialist->address;
dm_list_nodeadd(targetlist, ia->value.addr, strlen(ia->value.addr) + 1);
if (! ialist->next)
break;
ialist = ialist->next;
}

internet_address_list_destroy(ialisthead);

trace(TRACE_DEBUG, "%s,%s: mail address parser found [%ld] email addresses",
__FILE__, __func__, targetlist->total_nodes);

if (targetlist->total_nodes == 0) /* no addresses found */
return -1;

return 0;
}

/* dump message(parts) to char ptrs */
gchar * dbmail_message_to_string(const struct DbmailMessage *self)
{
Expand Down
6 changes: 5 additions & 1 deletion dbmail-message.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct DbmailMessage * dbmail_message_retrieve(struct DbmailMessage *self, u64_t
void dbmail_message_set_physid(struct DbmailMessage *self, u64_t physid);
u64_t dbmail_message_get_physid(const struct DbmailMessage *self);

void dbmail_message_set_envelope_recipient(struct DbmailMessage *self, char *envelope);
void dbmail_message_set_envelope_recipient(struct DbmailMessage *self, const char *envelope);
gchar * dbmail_message_get_envelope_recipient(const struct DbmailMessage *self);

void dbmail_message_set_internal_date(struct DbmailMessage *self, char *internal_date);
Expand All @@ -116,6 +116,10 @@ size_t dbmail_message_get_size(const struct DbmailMessage *self, gboolean crlf);
size_t dbmail_message_get_hdrs_size(const struct DbmailMessage *self, gboolean crlf);
size_t dbmail_message_get_body_size(const struct DbmailMessage *self, gboolean crlf);

//FIXME: old api style
int dbmail_message_get_header_addresses(struct DbmailMessage *message,
const char *scan_for_field, struct dm_list *targetlist);

gchar * get_crlf_encoded(gchar *string);
/*
* manipulate the actual message content
Expand Down
1 change: 0 additions & 1 deletion dbmail.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
#include "imap4.h"
#include "imapcommands.h"
#include "memblock.h"
#include "mime.h"
#include "pidfile.h"
#include "forward.h"
#include "dbmd5.h"
Expand Down
Loading

0 comments on commit d07b6ee

Please sign in to comment.