Exemplo n.º 1
0
/**
 * camel_mime_filter_save_new:
 *
 * Create a new #CamelMimeFilterSave filter object.
 *
 * Returns a new #CamelMimeFilterSave object
 **/
CamelMimeFilter *
camel_mime_filter_save_new (void)
{
	CamelMimeFilterSave *save = CAMEL_MIME_FILTER_SAVE (camel_object_new (CAMEL_MIME_FILTER_SAVE_TYPE));

	save->stream = camel_stream_mem_new ();

	return (CamelMimeFilter *) save;
}
/**
 * camel_multipart_encrypted_new:
 *
 * Create a new #CamelMultipartEncrypted object.
 *
 * A MultipartEncrypted should be used to store and create parts of
 * type "multipart/encrypted".
 *
 * Returns a new #CamelMultipartEncrypted object
 **/
CamelMultipartEncrypted *
camel_multipart_encrypted_new (void)
{
	CamelMultipartEncrypted *multipart;

	multipart = (CamelMultipartEncrypted *) camel_object_new (CAMEL_MULTIPART_ENCRYPTED_TYPE);

	return multipart;
}
Exemplo n.º 3
0
/**
 * camel_mime_filter_save_new_with_stream:
 * @stream: a #CamelStream object
 *
 * Create a new #CamelMimeFilterSave filter object that will save a
 * copy of all filtered data to @stream.
 *
 * Returns a new #CamelMimeFilterSave object
 **/
CamelMimeFilter *
camel_mime_filter_save_new_with_stream (CamelStream *stream)
{
	CamelMimeFilterSave *save = CAMEL_MIME_FILTER_SAVE (camel_object_new (CAMEL_MIME_FILTER_SAVE_TYPE));

	save->stream = stream;
	camel_object_ref (stream);

	return (CamelMimeFilter *) save;
}
Exemplo n.º 4
0
CamelFolderSummary *
camel_imap4_summary_new (CamelFolder *folder)
{
	CamelFolderSummary *summary;

	summary = (CamelFolderSummary *) camel_object_new (CAMEL_TYPE_IMAP4_SUMMARY);
	summary->folder = folder;

	return summary;
}
/**
 * camel_imap_message_cache_new:
 * @path: directory to use for storage
 * @summary: CamelFolderSummary for the folder we are caching
 * @ex: a CamelException
 *
 * Return value: a new CamelImapMessageCache object using @path for
 * storage. If cache files already exist in @path, then any that do not
 * correspond to messages in @summary will be deleted.
 **/
CamelImapMessageCache *
camel_imap_message_cache_new (const char *path, CamelFolderSummary *summary,
			      CamelException *ex)
{
	CamelImapMessageCache *cache;
	GDir *dir;
	const char *dname;
	char *uid, *p;
	GPtrArray *deletes;
	CamelMessageInfo *info;
	GError *error = NULL;

	dir = g_dir_open (path, 0, &error);
	if (!dir) {
		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
				      _("Could not open cache directory: %s"),
				      error->message);
		g_error_free (error);
		return NULL;
	}

	cache = (CamelImapMessageCache *)camel_object_new (CAMEL_IMAP_MESSAGE_CACHE_TYPE);
	cache->path = g_strdup (path);

	cache->parts = g_hash_table_new (g_str_hash, g_str_equal);
	cache->cached = g_hash_table_new (NULL, NULL);
	deletes = g_ptr_array_new ();
	while ((dname = g_dir_read_name (dir))) {
		if (!isdigit (dname[0]))
			continue;
		p = strchr (dname, '.');
		if (p)
			uid = g_strndup (dname, p - dname);
		else
			uid = g_strdup (dname);

		info = camel_folder_summary_uid (summary, uid);
		if (info) {
			camel_message_info_free(info);
			cache_put (cache, uid, dname, NULL);
		} else
			g_ptr_array_add (deletes, g_strdup_printf ("%s/%s", cache->path, dname));
		g_free (uid);
	}
	g_dir_close (dir);

	while (deletes->len) {
		g_unlink (deletes->pdata[0]);
		g_free (deletes->pdata[0]);
		g_ptr_array_remove_index_fast (deletes, 0);
	}
	g_ptr_array_free (deletes, TRUE);

	return cache;
}
Exemplo n.º 6
0
static CamelSession *
camel_pgp_session_new (const char *path)
{
	CamelSession *session;

	session = CAMEL_SESSION (camel_object_new (CAMEL_PGP_SESSION_TYPE));

	camel_session_construct (session, path);

	return session;
}
Exemplo n.º 7
0
static CamelService *
get_service (CamelSession *session, const char *url_string,
	     CamelProviderType type, CamelException *ex)
{
	CamelURL *url;
	CamelProvider *provider;
	CamelService *service;
	CamelException internal_ex;

	url = camel_url_new (url_string, ex);
	if (!url)
		return NULL;

	/* We need to look up the provider so we can then lookup
	   the service in the provider's cache */
	provider = camel_provider_get(url->protocol, ex);
	if (provider && !provider->object_types[type]) {
		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
				      _("No provider available for protocol `%s'"),
				      url->protocol);
		provider = NULL;
	}

	if (!provider) {
		camel_url_free (url);
		return NULL;
	}

	/* If the provider doesn't use paths but the URL contains one,
	 * ignore it.
	 */
	if (url->path && !CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_PATH))
		camel_url_set_path (url, NULL);

	/* Now look up the service in the provider's cache */
//	service = camel_object_bag_reserve(provider->service_cache[type], url);
//	if (service == NULL) {
		service = (CamelService *)camel_object_new (provider->object_types[type]);
		camel_exception_init (&internal_ex);
		camel_service_construct (service, session, provider, url, &internal_ex);
		if (camel_exception_is_set (&internal_ex)) {
			camel_exception_xfer (ex, &internal_ex);
			camel_object_unref (service);
			service = NULL;
//			camel_object_bag_abort(provider->service_cache[type], url);
		} else {
//			camel_object_bag_add(provider->service_cache[type], url, service);
		}
//	}

	camel_url_free (url);

	return service;
}
Exemplo n.º 8
0
CamelSession *
camel_scalix_session_new (const char *path)
{
    CamelSession *session;

    session = CAMEL_SESSION (camel_object_new (E_CAMEL_SCALIX_SESSION_TYPE));

    camel_session_construct (session, path);

    return session;
}
/**
 * camel_pop3_stream_new:
 *
 * Returns a NULL stream.  A null stream is always at eof, and
 * always returns success for all reads and writes.
 *
 * Return value: the stream
 **/
CamelStream *
camel_pop3_stream_new(CamelStream *source)
{
	CamelPOP3Stream *is;

	is = (CamelPOP3Stream *)camel_object_new(camel_pop3_stream_get_type ());
	camel_object_ref((CamelObject *)source);
	is->source = source;

	return (CamelStream *)is;
}
/**
 * camel_stream_mem_new_with_byte_array:
 * @buffer: a #GByteArray to use as the stream data
 *
 * Create a new #CamelStreamMem using @buffer as the stream data.
 *
 * Note: The newly created #CamelStreamMem will destroy @buffer
 * when destroyed.
 *
 * Returns a new #CamelStreamMem
 **/
CamelStream *
camel_stream_mem_new_with_byte_array (GByteArray *buffer)
{
	CamelStreamMem *stream_mem;

	stream_mem = CAMEL_STREAM_MEM (camel_object_new (CAMEL_STREAM_MEM_TYPE));
	stream_mem->buffer = buffer;
	stream_mem->owner = TRUE;

	return CAMEL_STREAM (stream_mem);
}
CamelFolder *
camel_nntp_folder_new (CamelStore *parent, const char *folder_name, CamelException *ex)
{
	CamelFolder *folder;
	CamelNNTPFolder *nntp_folder;
	char *root;
	CamelService *service;
	CamelStoreInfo *si;
	gboolean subscribed = TRUE;

	service = (CamelService *) parent;
	root = camel_session_get_storage_path (service->session, service, ex);
	if (root == NULL)
		return NULL;

	/* If this doesn't work, stuff wont save, but let it continue anyway */
	g_mkdir_with_parents (root, 0777);

	folder = (CamelFolder *) camel_object_new (CAMEL_NNTP_FOLDER_TYPE);
	nntp_folder = (CamelNNTPFolder *)folder;

	camel_folder_construct (folder, parent, folder_name, folder_name);
	folder->folder_flags |= CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY|CAMEL_FOLDER_HAS_SEARCH_CAPABILITY;

	nntp_folder->storage_path = g_build_filename (root, folder->full_name, NULL);
	g_free (root);

	root = g_strdup_printf ("%s.cmeta", nntp_folder->storage_path);
	camel_object_set(nntp_folder, NULL, CAMEL_OBJECT_STATE_FILE, root, NULL);
	camel_object_state_read(nntp_folder);
	g_free(root);

	root = g_strdup_printf("%s.ev-summary", nntp_folder->storage_path);
	folder->summary = (CamelFolderSummary *) camel_nntp_summary_new (folder, root);
	g_free(root);
	camel_folder_summary_load (folder->summary);

	si = camel_store_summary_path ((CamelStoreSummary *) ((CamelNNTPStore*) parent)->summary, folder_name);
	if (si) {
		subscribed = (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) != 0;
		camel_store_summary_info_free ((CamelStoreSummary *) ((CamelNNTPStore*) parent)->summary, si);
	}

	if (subscribed) {
		camel_folder_refresh_info(folder, ex);
		if (camel_exception_is_set(ex)) {
			camel_object_unref (folder);
			folder = NULL;
		}
        }

	return folder;
}
CamelOfflineJournal *
camel_groupwise_journal_new (CamelGroupwiseFolder *folder, const char *filename)
{
	CamelOfflineJournal *journal;

	g_return_val_if_fail (CAMEL_IS_GROUPWISE_FOLDER (folder), NULL);

	journal = (CamelOfflineJournal *) camel_object_new (camel_groupwise_journal_get_type ());
	camel_offline_journal_construct (journal, (CamelFolder *) folder, filename);

	return journal;
}
/**
 * camel_imap4_stream_new:
 * @stream: tcp stream
 *
 * Returns a new imap4 stream
 **/
CamelStream *
camel_imap4_stream_new (CamelStream *stream)
{
	CamelIMAP4Stream *imap4;

	g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL);

	imap4 = (CamelIMAP4Stream *) camel_object_new (CAMEL_TYPE_IMAP4_STREAM);
	camel_object_ref (stream);
	imap4->stream = stream;

	return (CamelStream *) imap4;
}
Exemplo n.º 14
0
/**
 * camel_scalix_stream_new:
 * @stream: tcp stream
 *
 * Returns a new scalix stream
 **/
CamelStream *
camel_scalix_stream_new (CamelStream *stream)
{
	CamelSCALIXStream *scalix;
	
	g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL);
	
	scalix = (CamelSCALIXStream *) camel_object_new (CAMEL_TYPE_SCALIX_STREAM);
	camel_object_ref (stream);
	scalix->stream = stream;
	
	return (CamelStream *) scalix;
}
Exemplo n.º 15
0
static void
camel_vee_store_init (CamelVeeStore *obj)
{
	CamelStore *store = (CamelStore *)obj;

	/* we dont want a vtrash/vjunk on this one */
	store->flags &= ~(CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK);

	/* Set up unmatched folder */
	obj->unmatched_uids = g_hash_table_new (g_str_hash, g_str_equal);
	obj->folder_unmatched = (CamelVeeFolder *)camel_object_new (camel_vee_folder_get_type ());
	camel_vee_folder_construct (obj->folder_unmatched, store, CAMEL_UNMATCHED_NAME, _("Unmatched"), CAMEL_STORE_FOLDER_PRIVATE);
}
Exemplo n.º 16
0
/**
 * camel_sasl_anonymous_new:
 * @type: trace type
 * @trace_info: trace info
 *
 * Create a new #CamelSaslAnonymous object.
 *
 * Returns a new #CamelSasl object
 **/
CamelSasl *
camel_sasl_anonymous_new (CamelSaslAnonTraceType type, const char *trace_info)
{
	CamelSaslAnonymous *sasl_anon;

	if (!trace_info && type != CAMEL_SASL_ANON_TRACE_EMPTY) return NULL;

	sasl_anon = CAMEL_SASL_ANONYMOUS (camel_object_new (camel_sasl_anonymous_get_type ()));
	sasl_anon->trace_info = g_strdup (trace_info);
	sasl_anon->type = type;

	return CAMEL_SASL (sasl_anon);
}
Exemplo n.º 17
0
/**
 * camel_mime_filter_crlf_new:
 * @direction: encode vs decode
 * @mode: whether or not to perform SMTP dot-escaping
 *
 * Create a new #CamelMimeFiletrCRLF object.
 *
 * Returns a new #CamelMimeFilterCRLF object
 **/
CamelMimeFilter *
camel_mime_filter_crlf_new (CamelMimeFilterCRLFDirection direction, CamelMimeFilterCRLFMode mode)
{
	CamelMimeFilterCRLF *crlf = CAMEL_MIME_FILTER_CRLF(camel_object_new (CAMEL_MIME_FILTER_CRLF_TYPE));

	crlf->direction = direction;
	crlf->mode = mode;
	crlf->saw_cr = FALSE;
	crlf->saw_lf = TRUE;
	crlf->saw_dot = FALSE;

	return (CamelMimeFilter *)crlf;
}
Exemplo n.º 18
0
/**
 * camel_smime_context_new:
 * @session: session
 *
 * Creates a new sm cipher context object.
 *
 * Returns a new sm cipher context object.
 **/
CamelCipherContext *
camel_smime_context_new(CamelSession *session)
{
	CamelCipherContext *cipher;
	CamelSMIMEContext *ctx;

	g_return_val_if_fail(CAMEL_IS_SESSION(session), NULL);

	ctx =(CamelSMIMEContext *) camel_object_new(camel_smime_context_get_type());

	cipher =(CamelCipherContext *) ctx;
	cipher->session = session;
	camel_object_ref(session);

	return cipher;
}
/**
 * camel_groupwise_summary_new:
 * @filename: the file to store the summary in.
 *
 * This will create a new CamelGroupwiseSummary object and read in the
 * summary data from disk, if it exists.
 *
 * Return value: A new CamelGroupwiseSummary object.
 **/
CamelFolderSummary *
camel_groupwise_summary_new (struct _CamelFolder *folder, const char *filename)
{
	CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (
			camel_object_new (camel_groupwise_summary_get_type ()));

	summary->folder = folder ;
	camel_folder_summary_set_build_content (summary, TRUE);
	camel_folder_summary_set_filename (summary, filename);

	if (camel_folder_summary_load (summary) == -1) {
		camel_folder_summary_clear (summary);
		camel_folder_summary_touch (summary);
	}

	return summary;
}
/**
 * camel_stream_vfs_new_with_stream:
 * @stream: a GInputStream or GOutputStream instance
 *
 * Creates a new fs stream using the given gio stream @stream as the
 * backing store. When the stream is destroyed, the file descriptor
 * will be closed. This will not increase reference counter on the stream.
 *
 * Returns a new #CamelStreamVFS
 **/
CamelStream *
camel_stream_vfs_new_with_stream (GObject *stream)
{
	CamelStreamVFS *stream_vfs;

	errno = EINVAL;

	if (!stream)
		return NULL;

	g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream) || G_IS_INPUT_STREAM (stream), NULL);

	errno = 0;
	stream_vfs = CAMEL_STREAM_VFS (camel_object_new (camel_stream_vfs_get_type ()));
	stream_vfs->stream = stream;

	return CAMEL_STREAM (stream_vfs);
}
/**
 * camel_seekable_substream_new:
 * @parent_stream: a #CamelSeekableStream object
 * @inf_bound: a lower bound
 * @sup_bound: an upper bound
 *
 * Creates a new CamelSeekableSubstream that references the portion
 * of @parent_stream from @inf_bound to @sup_bound. (If @sup_bound is
 * #CAMEL_STREAM_UNBOUND, it references to the end of stream, even if
 * the stream grows.)
 *
 * While the substream is open, the caller cannot assume anything about
 * the current position of @parent_stream. After the substream has been
 * closed, @parent_stream will stabilize again.
 *
 * Return value: the substream
 **/
CamelStream *
camel_seekable_substream_new(CamelSeekableStream *parent_stream, off_t start, off_t end)
{
	CamelSeekableSubstream *seekable_substream;

	g_return_val_if_fail (CAMEL_IS_SEEKABLE_STREAM (parent_stream), NULL);

	/* Create the seekable substream. */
	seekable_substream = CAMEL_SEEKABLE_SUBSTREAM (camel_object_new (camel_seekable_substream_get_type ()));

	/* Initialize it. */
	seekable_substream->parent_stream = parent_stream;
	camel_object_ref (parent_stream);

	/* Set the bound of the substream. We can ignore any possible error
	 * here, because if we fail to seek now, it will try again later.
	 */
	camel_seekable_stream_set_bounds ((CamelSeekableStream *)seekable_substream, start, end);

	return CAMEL_STREAM (seekable_substream);
}
CamelDiscoDiary *
camel_disco_diary_new (CamelDiscoStore *store, const char *filename, CamelException *ex)
{
	CamelDiscoDiary *diary;

	g_return_val_if_fail (CAMEL_IS_DISCO_STORE (store), NULL);
	g_return_val_if_fail (filename != NULL, NULL);

	diary = CAMEL_DISCO_DIARY (camel_object_new (CAMEL_DISCO_DIARY_TYPE));
	diary->store = store;

	d(printf("diary log file '%s'\n", filename));

	/* Note that the linux man page says:

	   a+     Open for reading and appending (writing at end  of  file).   The
	          file  is created if it does not exist.  The stream is positioned
		  at the end of the file.
	   However, c99 (which glibc uses?) says:
	   a+     append; open or create text file for update, writing at
	           end-of-file

	   So we must seek ourselves.
	*/

	diary->file = g_fopen (filename, "a+b");
	if (!diary->file) {
		camel_object_unref (diary);
		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
				      "Could not open journal file: %s",
				      g_strerror (errno));
		return NULL;
	}

	fseek(diary->file, 0, SEEK_END);

	d(printf(" is at %ld\n", ftell(diary->file)));

	return diary;
}
Exemplo n.º 23
0
CamelFolder *
camel_spool_folder_new(CamelStore *parent_store, const char *full_name, guint32 flags, CamelException *ex)
{
	CamelFolder *folder;

	d(printf("Creating spool folder: %s in %s\n", full_name, camel_local_store_get_toplevel_dir((CamelLocalStore *)parent_store)));

	folder = (CamelFolder *)camel_object_new(CAMEL_SPOOL_FOLDER_TYPE);

	if (parent_store->flags & CAMEL_STORE_FILTER_INBOX
	    && strcmp(full_name, "INBOX") == 0)
		folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
	flags &= ~CAMEL_STORE_FOLDER_BODY_INDEX;

	folder = (CamelFolder *)camel_local_folder_construct((CamelLocalFolder *)folder, parent_store, full_name, flags, ex);
	if (folder) {
		if (camel_url_get_param(((CamelService *)parent_store)->url, "xstatus"))
			camel_mbox_summary_xstatus((CamelMboxSummary *)folder->summary, TRUE);
	}

	return folder;
}
Exemplo n.º 24
0
/**
 * em_stripsig_filter_new:
 *
 * Creates a new stripsig filter.
 *
 * Returns a new stripsig filter.
 **/
CamelMimeFilter *
em_stripsig_filter_new (void)
{
	return (CamelMimeFilter *) camel_object_new (EM_TYPE_STRIPSIG_FILTER);
}
Exemplo n.º 25
0
/**
 * camel_mime_filter_charset_new:
 *
 * Create a new #CamelMimeFilterCharset object.
 *
 * Returns a new #CamelMimeFilterCharset object
 **/
CamelMimeFilterCharset *
camel_mime_filter_charset_new (void)
{
	return CAMEL_MIME_FILTER_CHARSET (camel_object_new (camel_mime_filter_charset_get_type ()));
}
CamelMimeFilter *
camel_mime_filter_pgp_new(void)
{
	return (CamelMimeFilter *) camel_object_new (camel_mime_filter_pgp_get_type ());
}
Exemplo n.º 27
0
/**
 * camel_nntp_store_summary_new:
 *
 * Create a new CamelNNTPStoreSummary object.
 *
 * Return value: A new CamelNNTPStoreSummary widget.
 **/
CamelNNTPStoreSummary *
camel_nntp_store_summary_new (void)
{
	return (CamelNNTPStoreSummary *) camel_object_new (camel_nntp_store_summary_get_type ());
}