Пример #1
0
void delete_multistring_class(void)
{
	SM_ENTER;
	if (CL_MultiString)
	{
		if (MUI_DeleteCustomClass(CL_MultiString))
		{
			SM_DEBUGF(15,("Deleted CL_MultiString: 0x%lx\n",CL_MultiString));
			CL_MultiString = NULL;
		} else
		{
			SM_DEBUGF(5,("FAILED! Delete CL_MultiString: 0x%lx\n",CL_MultiString));
		}
	}

	if (CL_SingleString)
	{
		if (MUI_DeleteCustomClass(CL_SingleString))
		{
			SM_DEBUGF(15,("Deleted CL_SingleString: 0x%lx\n",CL_SingleString));
			CL_SingleString = NULL;
		} else
		{
			SM_DEBUGF(5,("FAILED! Delete CL_SingleString: 0x%lx\n",CL_SingleString));
		}
	}
	SM_LEAVE;
}
Пример #2
0
void myclosesocket(int fd)
{
	long rc = CloseSocket(fd);
	if (rc != 0)
		SM_DEBUGF(5,("Closing socket %ld failed\n",fd));
	else
		SM_DEBUGF(20,("Closing socket %ld succeeded\n",fd));
}
Пример #3
0
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");
}
Пример #4
0
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");
}
Пример #5
0
/**
 * Function that is called when an email has been downloaded. It is assumed
 * that is called on parent task.
 *
 * @param m
 * @param userdata
 */
static void imap_download_mail_callback_on_parent_task(struct mail_info *m, void *userdata)
{
	struct imap_download_data *d = (struct imap_download_data*)userdata;
	struct folder *local_folder;

	SM_ENTER;

	SM_DEBUGF(20,("m=%p, d=%p, local_path=%p\n",m,d,d->local_path));

	folders_lock();
	if ((local_folder = folder_find_by_path(d->local_path)))
		folder_lock(local_folder);
	folders_unlock();

	if (local_folder)
	{
		folder_set_mail_flags(local_folder, m, (m->flags & (~MAIL_FLAGS_PARTIAL)));
		folder_unlock(local_folder);
	}
	d->callback(m,d->userdata);
	mail_dereference(m);
	free(d->remote_path);
	free(d->local_path);
	imap_free(d->server);
	free(d);

	SM_LEAVE;
}
Пример #6
0
VOID delete_transwnd_class(VOID)
{
	SM_ENTER;
	if (CL_transwnd)
	{
		if (MUI_DeleteCustomClass(CL_transwnd))
		{
			SM_DEBUGF(15,("Deleted CL_transwnd: 0x%lx\n",CL_transwnd));
			CL_transwnd = NULL;
		} else
		{
			SM_DEBUGF(5,("FAILED! Delete CL_transwnd: 0x%lx\n",CL_transwnd));
		}
	}
	SM_LEAVE;
}
Пример #7
0
/**
 * Close the socket lib.
 */
void close_socket_lib(void)
{
	struct thread_s *thread;

	SM_ENTER;

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

	SM_DEBUGF(10,("Socket library opened %ld times\n",thread->socketlib_opencnt-1));

	if (!(--thread->socketlib_opencnt))
	{
#ifdef __AMIGAOS4__
		if (thread->isocket)
		{
			DropInterface((struct Interface*)thread->isocket);
			thread->isocket = NULL;
		}
#endif
		if (thread->socketlib)
		{
			CloseLibrary(thread->socketlib);
			thread->socketlib = NULL;
		}
	}

out:
	SM_LEAVE;
}
Пример #8
0
void delete_pgplist_class(void)
{
	SM_ENTER;
	if (CL_PGPList)
	{
		if (MUI_DeleteCustomClass(CL_PGPList))
		{
			SM_DEBUGF(15,("Deleted CL_PGPList: 0x%lx\n",CL_PGPList));
			CL_PGPList = NULL;
		} else
		{
			SM_DEBUGF(5,("FAILED! Delete CL_PGPList: 0x%lx\n",CL_PGPList));
		}
	}
	SM_LEAVE;
}
Пример #9
0
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");
}
Пример #10
0
SSL_CTX *ssl_context(void)
{
	struct thread_s *thread = (struct thread_s*)FindTask(NULL)->tc_UserData;
	if (!thread) return NULL; /* assert */

	SM_DEBUGF(20,("ssl context = %p\n",thread->ssl_ctx));
	return (SSL_CTX *)thread->ssl_ctx;
}
Пример #11
0
void imap_thread_connect(struct folder *folder)
{
	struct imap_server *server;
	char *imap_folder;
	char *imap_local_path;

	SM_ENTER;

	if (!(server = account_find_imap_server_by_folder(folder)))
	{
		SM_DEBUGF(5,("Server for folder %p (%s) not found\n",folder,folder?folder->name:"NONE"));
		goto bailout;
	}

	if (!imap_start_thread())
	{
		SM_DEBUGF(5,("Could not start IMAP thread\n"));
		goto bailout;
	}

	if (!(server = imap_duplicate(server)))
	{
		SM_DEBUGF(5,("Could not duplicate imap server\n"));
		goto bailout;
	}

	if ((!(imap_folder = mystrdup(folder->imap_path))) && folder->imap_path != NULL && strlen(folder->imap_path))
	{
		SM_DEBUGF(5,("Could not duplicate imap path\n"));
		goto bailout;
	}

	if (!(imap_local_path = mystrdup(folder->path)))
	{
		SM_DEBUGF(5,("Could not duplicate folder path\n"));
		goto bailout;
	}

	thread_call_function_async(imap_thread, imap_thread_connect_to_server, 3, server, imap_folder, imap_local_path);
bailout:
	SM_LEAVE;
}
Пример #12
0
/**
 * 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;
}
Пример #13
0
void close_ssl_lib(void)
{
	struct thread_s *thread;

	SM_ENTER;

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

#ifndef NO_SSL
	if (!thread->ssllib_opencnt)
	{
		SM_LEAVE;
		return;
	}

	SM_DEBUGF(10,("AmiSSL opened %ld times\n",thread->ssllib_opencnt - 1));

	if (!(--thread->ssllib_opencnt))
	{
		SSL_CTX_free((SSL_CTX*)thread->ssl_ctx);
		thread->ssl_ctx = NULL;

#ifndef USE_OPENSSL
#ifdef USE_AMISSL3
		close_amissl3(thread);
#else
		CleanupAmiSSL(TAG_DONE);
		CloseLibraryInterface(thread->amissllib,thread->iamissl);
		thread->amissllib = NULL;
		thread->iamissl = NULL;
#endif
#endif
		close_socket_lib();
	}
#endif
out:
	SM_LEAVE;
}
Пример #14
0
char *text2html(unsigned char *buffer, int buffer_len, int flags, const char *fonttag)
{
	unsigned char *saved_buffer = buffer;
	string str;

	if (string_initialize(&str,1024))
	{
		char buf[512];
		int last_color = 0; /* the color of the current line */
		int eval_color = 2; /* recheck the color */
		int initial_color = 1;
		int level = 0;
		int line = 0; /* the type of the line */

		if (flags & TEXT2HTML_BODY_TAG)
		{
			sm_snprintf(buf,sizeof(buf),"<BODY BGCOLOR=\"#%06x\" TEXT=\"#%06x\" LINK=\"#%06x\">",user.config.read_background,user.config.read_text,user.config.read_link);
			string_append(&str,buf);
		}
		string_append(&str,fonttag); /* accepts NULL pointer */

		/* check for >0, otherwise we'll be in an endless loop if buffer_len becomes <0 */
		while (buffer_len > 0)
		{
			if (eval_color)
			{
				int new_level = 0;
				int buffer2_len = buffer_len;
				unsigned char *buffer2 = buffer;
				int new_color = 0;

				/* Determine the citation level. Afterwards, buffer2 will point to the end of the citation symbols. */
				while (buffer2_len)
				{
					unsigned char c = *buffer2;
					if (c == '>')
					{
						new_level++;
						if (new_color == 1) new_color = 2;
						else new_color = 1;
					} else
					{
						if (c != ' ') break;
						if (c == ' ' && !new_level) break;
					}
					buffer2_len--;
					buffer2++;
				}

				if (user.config.read_graphical_quote_bar)
				{
					/* When graphical quote bar is enabled we skip all quotation symbols */
					buffer = buffer2;
					buffer_len = buffer2_len;

					if (level != new_level)
					{
						const char *begin_quote_string = "<TABLE BGCOLOR=\"#%06x\" WIDTH=\"100%%\" STYLE=\"border-left: 3px solid #%06x; border-right: 3px solid #%06x;\"><TD><FONT COLOR=\"#%06x\">";
						const char *end_quote_string = "</FONT></TD></TABLE>";

						/* If new level is larger */
						for (;level < new_level; level++)
						{
							unsigned int color = level%2?user.config.read_quoted:user.config.read_old_quoted;
							sm_snprintf(buf,sizeof(buf),begin_quote_string,user.config.read_quoted_background,color,color,color);
							string_append(&str,buf);
						}

						/* If new level is lower */
						for (;level > new_level; level--)
							string_append(&str,end_quote_string);
					}
				} else
				{
					if (last_color != new_color)
					{
						const char *begin_quote_string = "<FONT COLOR=\"#%x\">";
						const char *end_quote_string = "</FONT>";

						if (!initial_color) string_append(&str,end_quote_string);
						if (new_color == 1)
						{
							sm_snprintf(buf,sizeof(buf),begin_quote_string,user.config.read_quoted);
							string_append(&str,buf);
						}
						else if (new_color == 2)
						{
							sm_snprintf(buf,sizeof(buf),begin_quote_string,user.config.read_old_quoted);
							string_append(&str,buf);
						}
						last_color = new_color;
						if (new_color) initial_color = 0;
						else initial_color = 1;
					}
				}
				eval_color = 0;
			}

			if (!mystrnicmp("http:",(char*)buffer,5)) write_uri(&buffer, &buffer_len, &str);
			else if (!mystrnicmp("mailto:",(char*)buffer,7)) write_uri(&buffer, &buffer_len, &str);
			else if (!mystrnicmp("ftp:",(char*)buffer,4)) write_uri(&buffer, &buffer_len, &str);
			else if (!mystrnicmp("https:",(char*)buffer,6)) write_uri(&buffer, &buffer_len, &str);
			else
			{
				unsigned char c;

				c = *buffer;

				if ((c == '@') && (buffer > saved_buffer))
				{
					/* A @ has been encountered, check if this belongs to an email adresse by traversing back
           * within the string */

					unsigned char *buffer2 = buffer - 1;
					unsigned char *buffer3;
					unsigned char c2;
					int buffer2_len = buffer_len + 1;
					char *address;

					while ((c2 = *buffer2) && buffer2 > saved_buffer)
					{
						static const char noaliaschars[] = {
							" ()<>@,;:\\\"[]\n\r"};

						if (strchr(noaliaschars,c2))
						{
							buffer2++;
							break;
						}
						buffer2_len++;
						buffer2--;
					}

					if ((buffer3 = (unsigned char*)parse_addr_spec((char*)buffer2, &address)))
					{
						int email_len;

						/* crop the string to the beginning of the email address */
						string_crop(&str,0,str.len - (buffer - buffer2));

						buffer_len += buffer - buffer2;
						buffer -= buffer - buffer2;
						email_len = buffer3 - buffer;
						buffer_len -= email_len;

						buffer = buffer3;

						sm_snprintf(buf,sizeof(buf),"<A HREF=\"mailto:%s\"%s>",address, user.config.read_link_underlined?"":" STYLE=\"TEXT-DECORATION: none\"");
						string_append(&str,buf);
						write_unicode(address,&str);
						string_append(&str,"</A>");
						free(address);
						continue;
					}
				}

		  	if (user.config.read_smilies)
		  	{
		  		unsigned int i;
		  		int smily_used = 0;
			  	/* No look into the smily table, this is slow and needs to be improved */
		  		for (i=0;i<sizeof(smily)/sizeof(struct smily);i++)
		  		{
		  			if (!strncmp(smily[i].ascii,(char*)buffer,strlen(smily[i].ascii)))
		  			{
		  				buffer += strlen(smily[i].ascii);
		  				buffer_len -= strlen(smily[i].ascii);
		  				sm_snprintf(buf,sizeof(buf),"<IMG SRC=\"PROGDIR:Images/%s\" VALIGN=\"middle\" ALT=\"%s\">",smily[i].gfx,smily[i].ascii);
		  				string_append(&str,buf);
		  				smily_used = 1;
		  			}
		  		}
		  		if (smily_used) continue;
		  	}

				if (!strncmp("\n<sb>",(char*)buffer,5))
				{
					if (line) string_append(&str,"<BR></TD><TD WIDTH=\"50%\"><HR></TD></TR></TABLE>");
					line = 1;
					buffer += 5;
					buffer_len -= 5;

					string_append(&str,"<TABLE WIDTH=\"100%\" BORDER=\"0\"><TR><TD VALIGN=\"middle\" WIDTH=\"50%\"><HR></TD><TD>");
					continue;
				}

				if (!strncmp("\n<tsb>",(char*)buffer,6))
				{
					if (line) string_append(&str,"<BR></TD><TD WIDTH=\"50%\"><HR></TD></TR></TABLE>");
					line = 2;
					buffer += 6;
					buffer_len -= 6;

					string_append(&str,"<TABLE WIDTH=\"100%\" BORDER=\"0\"><TR><TD VALIGN=\"middle\" WIDTH=\"50%\"><HR></TD><TD>");
					continue;
				}

				if (c < 128)
				{
					buffer++;
					buffer_len--;
					if (c== '<') string_append(&str,"&lt;");
					else if (c== '>') string_append(&str,"&gt;");
					else if (c== '&') string_append(&str,"&amp;");
					else if (c == 10)
					{
						eval_color = 1;
						string_append(&str,"<BR>\n");
						if (line)
						{
							string_append(&str,"</TD><TD WIDTH=\"50%\"><HR></TD></TR></TABLE>");
							line = 0;
						}
					} else
					{
						if (c == 32) {
							if (*buffer == 32 || (flags & TEXT2HTML_NOWRAP)) string_append(&str,"&nbsp;");
							else string_append(&str," ");
						} else {
						  if (c)
						  {
						  	string_append_part(&str,(char*)&c,1);
						  }
						}
					}
				} else
				{
					unsigned int unicode;
					int len = 0;
					/* check if it really could be a utf8 char */
					if (utf8islegal((utf8*)buffer, (utf8*)(buffer+buffer_len)))
					{
						len = utf8tochar((utf8*)buffer, &unicode, user.config.default_codeset);
					}
					if ((len == 0) || (len > buffer_len))
					{
						/* something wrong with that utf8 sequence */
						unicode = '?';
						len = 1;
					}
					buffer_len -= len;
					buffer += len;

					if (unicode == 0) unicode = '_';
					sm_snprintf(buf,sizeof(buf),"&#%d;",unicode);
					string_append(&str,buf);
				}
			}
		}

		if (fonttag) string_append(&str,"</FONT>");

		if (flags & TEXT2HTML_ENDBODY_TAG) string_append(&str,"</BODY>");

		SM_DEBUGF(20,("%s\n",str.str));

		return str.str;
	}
	return NULL;
}
Пример #15
0
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
}
Пример #16
0
/**
 * Handle this single ARexx message.
 *
 * @param rxmsg
 * @return
 */
static int arexx_message(struct RexxMsg *rxmsg)
{
	STRPTR command_line = (STRPTR)ARG0(rxmsg);
	APTR command_handle;

	struct {
		STRPTR command;
		STRPTR args;
	} command;

	command.command = command.args = NULL;
	rxmsg->rm_Result1 = 0;
	rxmsg->rm_Result2 = 0;

	SM_DEBUGF(5,("Received ARexx command: \"%s\"\n",command_line));

	if ((command_handle = ParseTemplate("COMMAND/A,ARGS/F",command_line,(LONG*)&command)))
	{
		if (!Stricmp("MAINTOFRONT",command.command)) arexx_maintofront(rxmsg,command.args);
		else if (!Stricmp("MAILWRITE",command.command)) arexx_mailwrite(rxmsg,command.args);
		else if (!Stricmp("WRITEATTACH",command.command)) arexx_writeattach(rxmsg,command.args);
		else if (!Stricmp("WRITECLOSE",command.command)) arexx_writeclose(rxmsg,command.args);
		else if (!Stricmp("SETMAIL",command.command)) arexx_setmail(rxmsg,command.args);
		else if (!Stricmp("SETMAILFILE",command.command)) arexx_setmailfile(rxmsg,command.args);
		else if (!Stricmp("SHOW",command.command)) arexx_show(rxmsg,command.args);
		else if (!Stricmp("HIDE",command.command)) arexx_hide(rxmsg,command.args);
		else if (!Stricmp("QUIT",command.command)) arexx_quit(rxmsg,command.args);
		else if (!Stricmp("GETSELECTED",command.command)) arexx_getselected(rxmsg,command.args);
		else if (!Stricmp("GETMAILSTAT",command.command)) arexx_getmailstat(rxmsg,command.args);
		else if (!Stricmp("FOLDERINFO",command.command)) arexx_folderinfo(rxmsg,command.args);
		else if (!Stricmp("REQUEST",command.command)) arexx_request(rxmsg,command.args);
		else if (!Stricmp("REQUESTSTRING",command.command)) arexx_requeststring(rxmsg,command.args);
		else if (!Stricmp("REQUESTFILE",command.command)) arexx_requestfile(rxmsg,command.args);
		else if (!Stricmp("MAILINFO",command.command)) arexx_mailinfo(rxmsg,command.args);
		else if (!Stricmp("SETFOLDER",command.command)) arexx_setfolder(rxmsg,command.args);
		else if (!Stricmp("ADDRGOTO",command.command)) arexx_addrgoto(rxmsg,command.args);
		else if (!Stricmp("ADDRNEW",command.command)) arexx_addrnew(rxmsg,command.args);
		else if (!Stricmp("ADDRSAVE",command.command)) arexx_addrsave(rxmsg,command.args);
		else if (!Stricmp("ADDRLOAD",command.command)) arexx_addrload(rxmsg,command.args);
		else if (!Stricmp("GETURL",command.command)) arexx_geturl(rxmsg,command.args);
		else if (!Stricmp("NEWMAILFILE",command.command)) arexx_newmailfile(rxmsg,command.args);
		else if (!Stricmp("MAILREAD",command.command)) arexx_mailread(rxmsg,command.args);
		else if (!Stricmp("READCLOSE",command.command)) arexx_readclose(rxmsg,command.args);
		else if (!Stricmp("READINFO",command.command)) arexx_readinfo(rxmsg,command.args);
		else if (!Stricmp("READSAVE",command.command)) arexx_readsave(rxmsg,command.args);
		else if (!Stricmp("SCREENTOBACK",command.command)) {struct Screen *scr = (struct Screen *)main_get_screen(); if (scr) ScreenToBack(scr);}
		else if (!Stricmp("SCREENTOFRONT",command.command)) {struct Screen *scr = (struct Screen *)main_get_screen(); if (scr) ScreenToFront(scr);}
		else if (!Stricmp("REQUESTFOLDER",command.command)) arexx_requestfolder(rxmsg,command.args);
		else if (!Stricmp("MAILADD",command.command)) arexx_mailadd(rxmsg,command.args);
		else if (!Stricmp("MAILSETSTATUS",command.command)) arexx_mailsetstatus(rxmsg,command.args);
		else if (!Stricmp("MAILLISTFREEZE",command.command)) main_freeze_mail_list();
		else if (!Stricmp("MAILLISTTHAW",command.command)) main_thaw_mail_list();
		else if (!Stricmp("MAILFETCH",command.command)) arexx_mailfetch(rxmsg,command.args);
		else if (!Stricmp("OPENMESSAGE",command.command)) arexx_openmessage(rxmsg,command.args);
		else if (!Stricmp("VERSION",command.command)) arexx_version(rxmsg,command.args);
		else if (!Stricmp("MAILMOVE",command.command)) arexx_mailmove(rxmsg,command.args);
		else if (!Stricmp("MAILDELETE",command.command)) arexx_maildelete(rxmsg,command.args);
		else rxmsg->rm_Result1 = 20;

		FreeTemplate(command_handle);
	}
	return 0;
}
Пример #17
0
STATIC ULONG transwnd_Set(struct IClass *cl, Object *obj, struct opSet *msg)
{
	int close = 0;
	ULONG rc;
	struct transwnd_Data *data;
	struct TagItem *tags, *tag;

	char *gauge1_str = NULL;
	int gauge1_max = -1;
	int gauge1_val = -1;
	int gauge1_div = 1;

	data = (struct transwnd_Data *) INST_DATA(cl, obj);

	for ((tags = msg->ops_AttrList); (tag = NextTagItem((APTR)&tags));)
	{
		switch (tag->ti_Tag)
		{
			case MUIA_transwnd_Status:
				set(data->status, MUIA_Text_Contents, tag->ti_Data);
				break;

			case MUIA_transwnd_Gauge1_Str:
				gauge1_str = (char*)tag->ti_Data;
				break;

			case MUIA_transwnd_Gauge1_Max:
				gauge1_max = tag->ti_Data;
				/* 16bit only */
				while (gauge1_max > 65535)
				{
					gauge1_max >>= 1;
					gauge1_div <<= 1;
				}
				SM_DEBUGF(20,("Gauge_Max: real=%ld mui=%ld div=%ld\n",tag->ti_Data, gauge1_max, gauge1_div));
				break;

			case MUIA_transwnd_Gauge1_Val:
				gauge1_val = tag->ti_Data;
				break;

			case MUIA_transwnd_Head:
				set(data->head,MUIA_Text_Contents, tag->ti_Data);
				break;

			case MUIA_transwnd_Gauge2_Str:
/*				set(data->gauge2, MUIA_Gauge_InfoText, tag->ti_Data); */
				break;

			case MUIA_transwnd_Gauge2_Max:
/*				set(data->gauge2, MUIA_Gauge_Max, tag->ti_Data); */
				break;

			case MUIA_transwnd_Gauge2_Val:
/*				set(data->gauge2, MUIA_Gauge_Current, tag->ti_Data); */
				break;

			case MUIA_transwnd_QuietList:
				set(data->mail_list, MUIA_NList_Quiet, tag->ti_Data);
				break;

			case MUIA_Window_Open:
				if (!tag->ti_Data) close = 1;
				break;
		}
	}

	if (gauge1_str || gauge1_max != -1 || gauge1_val != -1)
	{
		SetAttrs(data->gauge1,
					gauge1_str==NULL?TAG_IGNORE:MUIA_Gauge_InfoText, gauge1_str,
					gauge1_max==-1?TAG_IGNORE:MUIA_Gauge_Max, gauge1_max,
					gauge1_max==-1?TAG_IGNORE:MUIA_Gauge_Divide, gauge1_div==1?0:gauge1_div,
					gauge1_val==-1?TAG_IGNORE:MUIA_Gauge_Current, gauge1_val,
					TAG_DONE);
	}

	rc = DoSuperMethodA(cl, obj, (Msg)msg);
	if (close)
	{
		if (data->mail_group_shown)
		{
			set(data->mail_group, MUIA_ShowMe, FALSE);
			data->mail_group_shown = 0;
		}

		DoMethod(data->mail_list, MUIM_NList_Clear);
		SetAttrs(obj,
/*			MUIA_Window_Title,"SimpleMail", */
			MUIA_transwnd_Status, _("Waiting..."),
			MUIA_transwnd_Gauge1_Str, _("Waiting..."),
			MUIA_transwnd_Gauge1_Max, 1,
			MUIA_transwnd_Gauge1_Val, 0,
			MUIA_transwnd_Gauge2_Str, _("Waiting..."),
			MUIA_transwnd_Gauge2_Max, 1,
			MUIA_transwnd_Gauge2_Val, 0,
			TAG_DONE);
	}
	return rc;
}
Пример #18
0
static void arch_debug_load(void)
{
	BPTR fh;
	char prog_name[64];
	char *buf = NULL;
	ULONG val;
	int buf_size, buf_pos;
	int table_size;
	int hunk;
	int hunk_type;
	int first_hunk;
	int last_hunk;
	int guard;

	if (arch_debug_loaded) return;

	arch_debug_loaded = 1;

	if (!(GetProgramName(prog_name,sizeof(prog_name))))
		return;

	if (!(fh = Open(prog_name,MODE_OLDFILE)))
		goto bailout;

	Seek(fh,0,OFFSET_END);
	buf_size = Seek(fh,0,OFFSET_BEGINNING);

	if (!(buf = (char*)malloc(buf_size)))
		goto bailout;

	if (Read(fh,buf,buf_size) != buf_size)
		goto bailout;

	buf_pos = 0;

#define CHECK_EOF {if (buf_pos >= buf_size) goto bailout;}
#define GET_ULONG {CHECK_EOF; val = (*(ULONG*)&buf[buf_pos]); buf_pos+=4;}
	GET_ULONG;
	if (val != HUNK_HEADER)
		goto bailout;

	GET_ULONG;
	if (val != 0)
		goto bailout;

	GET_ULONG; table_size = val;
	GET_ULONG; first_hunk = val;
	GET_ULONG; last_hunk = val;

	buf_pos += table_size * 4;
	CHECK_EOF;

	for (guard = 0, hunk = first_hunk;hunk <= last_hunk && guard < 1000; guard++)
	{
		SM_DEBUGF(20,("Scanning hunk %d\n",hunk));

		GET_ULONG; hunk_type = val & 0x3FFFFFFF;

		switch (hunk_type)
		{
			case	HUNK_DEBUG:
					{
						int lwd;
						int next_hunk_buf_pos;

						ULONG hunk_size;
						ULONG base_offset;

						GET_ULONG; hunk_size = val;
						next_hunk_buf_pos = buf_pos + hunk_size * 4;
						GET_ULONG; base_offset = val;

						for (lwd = 0; lwd < 20 && lwd < hunk_size; lwd++)
						{
							GET_ULONG; /* type of debug info */

							switch (val)
							{
								case	MAKE_ID('S','R','C',' '):
										break;

								case	MAKE_ID('L','I','N','E'):
										{
											int name_size;
											char *name;

											GET_ULONG; name_size = val;

											name = mystrdup((char*)&buf[buf_pos]);

											buf_pos += name_size * 4;

											while(buf_pos < next_hunk_buf_pos && guard < 1000)
											{
												ULONG line, junk;

												struct debug_info dbi;

												GET_ULONG; line = val;
												GET_ULONG; junk = val;

												dbi.filename = name;
												dbi.line = line & 0xffffff;
												dbi.offset = junk + base_offset;
												arch_debug_info_add(&dbi);
											}
										}
										break;
							}
						}
						buf_pos = next_hunk_buf_pos;
					}
					break;

			case	HUNK_CODE:
			case	HUNK_DATA:
			case	HUNK_NAME:
					{
						ULONG hunk_size;
						GET_ULONG; hunk_size = val;
						buf_pos += hunk_size * 4;
					}
					break;

			case	HUNK_RELOC32:
			case	HUNK_SYMBOL:
					{
						ULONG num_relocs;
						do
						{
							GET_ULONG; num_relocs = val;

							if (num_relocs)
							{
								/* Skip the number of relocs plus the hunk to which they refer */
								buf_pos += num_relocs * 4 + 4;
							}
						} while (num_relocs);
					}
					break;

			case	HUNK_END:
					hunk++;
					break;

			default:
					goto bailout;
		}
	}

	if (debug_info_count)
	{
		struct debug_info *di;
		struct debug_info dummy;

		dummy.offset = 0;
		dummy.line = 0;
		dummy.filename = "";
		arch_debug_info_add(&dummy);

		dummy.offset = 0x7fffff;
		arch_debug_info_add(&dummy);

		qsort(debug_info_array,debug_info_count, sizeof(debug_info_array[0]), debug_info_cmp);
	}

bailout:
	free(buf);
	if (fh) Close(fh);
}
Пример #19
0
int read_window_open(const char *folder, struct mail_info *mail, int window)
{
	int w, h;
	char buf[256];

	getmaxyx(stdscr, h, w);
	h -= 2;

	if (!read_wnd)
	{
		read_wnd = newwin(h, w, 0, 0);
		read_panel = new_panel(read_wnd);
		show_panel(read_panel);
	} else
	{
		show_panel(read_panel);
		update_panels();
		doupdate();
	}

	gui_add_resize_listener(&resize_listener, read_window_resize, NULL);
	resize_listener_added = 1;

	if (read_current_mail)
	{
		mail_complete_free(read_current_mail);
	}

	getcwd(buf, sizeof(buf));
	chdir(folder);

	if ((read_current_mail = mail_complete_create_from_file(NULL, mail->filename)))
	{
		struct mail_complete *initial;
		mail_read_contents(NULL,read_current_mail);
		if ((initial = mail_find_initial(read_current_mail)))
		{
			char buf[380];
			utf8 *from_phrase = mail_info_get_from_phrase(read_current_mail->info);
			utf8 *from_addr = mail_info_get_from_addr(read_current_mail->info);
			if (from_phrase)
			{
				sm_snprintf(buf, sizeof(buf), "%s: %s <%s>", _("From"), from_phrase, from_addr);
			} else
			{
				sm_snprintf(buf, sizeof(buf), "%s: %s", _("From"), from_addr);
			}
			gadgets_init_simple_text_label(&from_label, buf);

			sm_snprintf(buf, sizeof(buf), "%s: %s", _("Date"), sm_get_date_str(read_current_mail->info->seconds));
			gadgets_init_simple_text_label(&date_label, buf);

			sm_snprintf(buf, sizeof(buf), "%s: %s", _("Subject"), read_current_mail->info->subject);
			gadgets_init_simple_text_label(&subject_label, buf);

			mail_decode(initial);

			gadgets_init_group(&read_group);
			gadgets_init_text_view(&text_view, initial->decoded_data);

			gadgets_add(&read_group, &from_label.tl.g);
			gadgets_add(&read_group, &date_label.tl.g);
			gadgets_add(&read_group, &subject_label.tl.g);
			gadgets_add(&read_group, &text_view.tl.tl.g);

			read_window_layout();

			gadgets_display(read_wnd, &read_group.g);
		}
	} else
	{
		SM_DEBUGF(20, ("Unable to create mail \"%s\"\n", mail->filename));
	}

	chdir(buf);

	gui_add_key_listener(&close_listener, 'c', "Close", read_window_close_current);
	refresh();

	wrefresh(read_wnd);

	return 1;
}
Пример #20
0
/**
 * 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;
}