コード例 #1
0
ファイル: transwndclass.c プロジェクト: weechatter/simplemail
int create_transwnd_class(VOID)
{
	SM_ENTER;
	if ((CL_transwnd = CreateMCC(MUIC_Window, NULL, sizeof(struct transwnd_Data), transwnd_Dispatcher)))
	{
		SM_DEBUGF(15,("Create CL_transwnd: 0x%lx\n",CL_transwnd));
		SM_RETURN(1,"%ld");
	}
	SM_DEBUGF(5,("FAILED! Create CL_transwnd\n",CL_transwnd));
	SM_RETURN(0,"%ld");
}
コード例 #2
0
ファイル: pgplistclass.c プロジェクト: weechatter/simplemail
int create_pgplist_class(void)
{
	SM_ENTER;
	if ((CL_PGPList = CreateMCC(MUIC_NList,NULL,sizeof(struct PGPList_Data),PGPList_Dispatcher)))
	{
		SM_DEBUGF(15,("Create CL_PGPList: 0x%lx\n",CL_PGPList));
		SM_RETURN(1,"%ld");
	}
	SM_DEBUGF(5,("FAILED! Create CL_PGPList\n"));
	SM_RETURN(0,"%ld");
}
コード例 #3
0
ファイル: multistringclass.c プロジェクト: sba1/simplemail
int create_multistring_class(void)
{
	SM_ENTER;
	if ((CL_SingleString = CreateMCC(NULL, CL_UTF8String, sizeof(struct SingleString_Data), SingleString_Dispatcher)))
	{
		SM_DEBUGF(15,("Create CL_SingleString: 0x%lx\n",CL_SingleString));
		if ((CL_MultiString = CreateMCC(MUIC_Group, NULL, sizeof(struct MultiString_Data), MultiString_Dispatcher)))
		{
			SM_DEBUGF(15,("Create CL_MultiString: 0x%lx\n",CL_MultiString));
			SM_RETURN(TRUE,"%ld");
		}
		SM_DEBUGF(5,("FAILED! Create CL_MultiString\n"));
		SM_RETURN(FALSE,"%ld");
	}
	SM_DEBUGF(5,("FAILED! Create CL_SingleString\n"));
	SM_RETURN(FALSE,"%ld");
}
コード例 #4
0
ファイル: tcpip.c プロジェクト: sba1/simplemail
/**
 * Opens the socket lib. Must be done for every thread which want to use
 * bsd socket functions.
 */
int open_socket_lib(void)
{
	struct thread_s *thread;

	SM_ENTER;

	if (!(thread = (struct thread_s*)FindTask(NULL)->tc_UserData))
		goto out;

	if (!thread->socketlib)
	{
		if ((thread->socketlib = OpenLibrary("bsdsocket.library", 4)))
		{
#ifdef __AMIGAOS4__
			if ((thread->isocket = (struct SocketIFace*)GetInterface(thread->socketlib,"main",1,NULL)))
			{
#endif
				thread->socketlib_opencnt = 1;
				SM_DEBUGF(10,("Socket library opened %ld times\n",thread->socketlib_opencnt));
				SM_RETURN(1,"%ld");
				return 1;
#ifdef __AMIGAOS4__
			}
			CloseLibrary(thread->socketlib);
#endif
		}
	} else
	{
		thread->socketlib_opencnt++;
		SM_DEBUGF(10,("Socket library opened %ld times\n",thread->socketlib_opencnt));
		SM_RETURN(1,"%ld");
		return 1;
	}
out:
	SM_RETURN(0,"%ld");
	return 0;
}
コード例 #5
0
ファイル: imap_thread.c プロジェクト: sba1/simplemail
int imap_download_mail_async(struct folder *f, struct mail_info *m, void (*callback)(struct mail_info *m, void *userdata), void *userdata)
{
	struct imap_download_data *d = NULL;

	SM_ENTER;

	if (!imap_start_thread()) goto bailout;
	if (!(d = (struct imap_download_data *)malloc(sizeof(*d)))) goto bailout;
	memset(d,0,sizeof(*d));
	d->userdata = userdata;
	if (!(d->server = account_find_imap_server_by_folder(f))) goto bailout;
	if (!(d->server = imap_duplicate(d->server))) goto bailout;
	if (!(d->local_path = mystrdup(f->path))) goto bailout;
	if (!(d->remote_path = mystrdup(f->imap_path))) goto bailout;

	mail_reference(m);
	d->callback = callback;

	if (!thread_call_function_async(imap_thread, imap_thread_download_mail, 5, d->server, d->local_path, m, imap_download_mail_async_callback, (void*)d))
		goto bailout;
	SM_RETURN(1,"%ld");
	return 1;
bailout:
	if (d)
	{
		if (d->remote_path)
		{
			free(d->remote_path);
			mail_dereference(m);
		}
		free(d->local_path);
		imap_free(d->server);
		free(d);
	}
	SM_RETURN(0,"%ld");
	return 0;
}
コード例 #6
0
ファイル: tcpip.c プロジェクト: sba1/simplemail
int open_ssl_lib(void)
{
#ifdef NO_SSL
	return 0;
#else
	struct thread_s *thread;

	SM_ENTER;

	if (!(thread = (struct thread_s*)FindTask(NULL)->tc_UserData))
		goto out;
	if (!open_socket_lib())
		goto out;
#ifndef USE_OPENSSL
	if (!thread->amissllib)
	{

#ifdef USE_AMISSL3
		if (open_amissl3(thread))
		{
#else
		SM_DEBUGF(10,("Open amissl.library\n"));
		if ((thread->amissllib = OpenLibraryInterface("amissl.library",1,&thread->iamissl)))
		{
			if (!InitAmiSSL(AmiSSL_Version,
					AmiSSL_CurrentVersion,
					AmiSSL_Revision, AmiSSL_CurrentRevision,
					AmiSSL_SocketBase, (ULONG)SocketBase,
					/*	AmiSSL_VersionOverride, TRUE,*/ /* If you insist */
					TAG_DONE))
			{
#endif
#endif
				if ((thread->ssl_ctx = ssl_create_context()))
				{
					/* Everything is ok */
					thread->ssllib_opencnt = 1;
					SM_DEBUGF(10,("AmiSSL opened %ld times\n",thread->ssllib_opencnt));
					SM_RETURN(1,"%ld");
					return 1;
				}
#ifndef USE_OPENSSL
#ifdef USE_AMISSL3
			close_amissl3(thread);
		}
#else
				CleanupAmiSSL(TAG_DONE);
			}
			CloseLibraryInterface(thread->amissllib,thread->iamissl);
			thread->iamissl = NULL;
			thread->amissllib = NULL;
		}
#endif

	} else
	{
		thread->ssllib_opencnt++;
		SM_DEBUGF(10,("AmiSSL opened %ld times\n",thread->ssllib_opencnt));
		SM_RETURN(1,"%ld");
		return 1;
	}
#else /* USE_OPENSSL */
	return 1;
#endif
out:
	close_socket_lib();
	SM_RETURN(0,"%ld");
	return 0;
#endif
}
コード例 #7
0
ファイル: imap_thread.c プロジェクト: sba1/simplemail
/**
 * Connect to the given imap server. Shall be invoked only in the context of the IMAP thread.
 *
 * @param server
 * @param folder
 * @param local_path
 * @return
 */
static int imap_thread_connect_to_server(struct imap_server *server, char *folder, char *local_path)
{
	static int connecting;

	int rc = 0;

	SM_ENTER;

	/* Ignore this request if we are already connecting. This can happen for instance, if a synchronous call
	 * to the parent task is issued.  */
	if (connecting)
	{
		SM_DEBUGF(5, ("Ignoring connect to server request for %s\n", local_path));

		if (server) imap_free(server);
		free(folder);
		free(local_path);
		goto bailout;
	}

	if (!imap_open_socket_lib())
		goto bailout;

	connecting = 1;

	if (!imap_connection || imap_new_connection_needed(imap_server,server))
	{
		struct imap_connect_to_server_options options = {0};

		imap_disconnect();

		if (imap_server) imap_free(imap_server);
		imap_server = server;

		free(imap_folder);
		imap_folder = folder;

		free(imap_local_path);
		imap_local_path = local_path;

		options.imap_local_path = imap_local_path;
		options.imap_server = imap_server;
		options.imap_folder = imap_folder;
		options.callbacks.set_status = imap_set_status;
		options.callbacks.request_login = imap_request_login;
		options.callbacks.add_imap_folder = imap_add_imap_folder;
		options.callbacks.refresh_folders = imap_refresh_folders;
		options.download_callbacks.new_uids = imap_new_uids;
		options.download_callbacks.new_mails_arrived = imap_new_mails_arrived;
		options.download_callbacks.set_status = imap_set_status;
		options.download_callbacks.set_status_static = imap_set_status_static;
		imap_really_connect_to_server(&imap_connection, &options);
		rc = 1;
	} else
	{
		struct imap_download_mails_options download_options = {0};

		imap_free(server);

		free(imap_folder);
		imap_folder = folder;

		free(imap_local_path);
		imap_local_path = local_path;

		download_options.imap_folder = imap_folder;
		download_options.imap_server = imap_server;
		download_options.imap_local_path = imap_local_path;

		download_options.callbacks.new_mails_arrived = imap_new_mails_arrived;
		download_options.callbacks.new_uids = imap_new_uids;
		download_options.callbacks.set_status = imap_set_status;
		download_options.callbacks.set_status_static = imap_set_status_static;
		download_options.callbacks.delete_mail_by_uid = imap_delete_mail_by_uid;

		imap_really_download_mails(imap_connection, &download_options);
		rc = 1;
	}

	connecting = 0;

bailout:
	SM_RETURN(rc,"%d");
	return rc;
}