text stringlengths 0 357 |
|---|
} |
return mime; |
// free_mime: |
//mailmime_free(mime); |
goto err; |
free_mime_fields: |
mailmime_fields_free(mime_fields); |
mailmime_content_free(content); |
goto err; |
free_content: |
if (encoding!=NULL) |
mailmime_mechanism_free(encoding); |
if (content!=NULL) |
mailmime_content_free(content); |
err: |
return NULL; |
} |
/** |
* Check if a MIME structure contains a multipart/report part. |
* |
* As reports are often unencrypted, we do not reset the Autocrypt header in |
* this case. |
* |
* However, Delta Chat itself has no problem with encrypted multipart/report |
* parts and MUAs should be encouraged to encrpyt multipart/reports as well so |
* that we could use the normal Autocrypt processing. |
* |
* @private |
* @param mime The mime struture to check |
* @return 1=multipart/report found in MIME, 0=no multipart/report found |
*/ |
static int contains_report(struct mailmime* mime) |
{ |
if (mime->mm_type==MAILMIME_MULTIPLE) |
{ |
if (mime->mm_content_type->ct_type->tp_type==MAILMIME_TYPE_COMPOSITE_TYPE |
&& mime->mm_content_type->ct_type->tp_data.tp_composite_type->ct_type==MAILMIME_COMPOSITE_TYPE_MULTIPART |
&& strcmp(mime->mm_content_type->ct_subtype, "report")==0) { |
return 1; |
} |
clistiter* cur; |
for (cur=clist_begin(mime->mm_data.mm_multipart.mm_mp_list); cur!=NULL; cur=clist_next(cur)) { |
if (contains_report((struct mailmime*)clist_content(cur))) { |
return 1; |
} |
} |
} |
else if (mime->mm_type==MAILMIME_MESSAGE) |
{ |
if (contains_report(mime->mm_data.mm_message.mm_msg_mime)) { |
return 1; |
} |
} |
return 0; |
} |
/******************************************************************************* |
* Generate Keypairs |
******************************************************************************/ |
static int load_or_generate_self_public_key(dc_context_t* context, dc_key_t* public_key, const char* self_addr, |
struct mailmime* random_data_mime /*for an extra-seed of the random generator. For speed reasons, only give _available_ pointers here, do not create any data - in very most cases, the key is not generated!*/) |
{ |
static int s_in_key_creation = 0; /* avoid double creation (we unlock the database during creation) */ |
int key_created = 0; |
int success = 0, key_creation_here = 0; |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || public_key==NULL) { |
goto cleanup; |
} |
if (!dc_key_load_self_public(public_key, self_addr, context->sql)) |
{ |
/* create the keypair - this may take a moment, however, as this is in a thread, this is no big deal */ |
if (s_in_key_creation) { goto cleanup; } |
key_creation_here = 1; |
s_in_key_creation = 1; |
/* seed the random generator */ |
{ |
uintptr_t seed[4]; |
seed[0] = (uintptr_t)time(NULL); /* time */ |
seed[1] = (uintptr_t)seed; /* stack */ |
seed[2] = (uintptr_t)public_key; /* heap */ |
seed[3] = (uintptr_t)pthread_self(); /* thread ID */ |
dc_pgp_rand_seed(context, seed, sizeof(seed)); |
if (random_data_mime) { |
MMAPString* random_data_mmap = NULL; |
int col = 0; |
if ((random_data_mmap=mmap_string_new(""))==NULL) { |
goto cleanup; |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.