dslinux/user/pixil/apps/fltk/mail/src Makefile actions.cxx actions.h callbacks.cxx callbacks.h db_defs.h maildefs.h mailengine.cxx mailengine.h main.cxx menu_defs.h mime.cxx mime.h nanomail.h pixmap.h settings.cxx settings.h ui.cxx ui.h

amadeus dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:24:25 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/pixil/apps/fltk/mail/src
In directory antilope:/tmp/cvs-serv11916/apps/fltk/mail/src

Added Files:
	Makefile actions.cxx actions.h callbacks.cxx callbacks.h 
	db_defs.h maildefs.h mailengine.cxx mailengine.h main.cxx 
	menu_defs.h mime.cxx mime.h nanomail.h pixmap.h settings.cxx 
	settings.h ui.cxx ui.h 
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it

--- NEW FILE: maildefs.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef MAILDEFS_H
#define MAILDEFS_H

#include "nxmail.h"

#define MAIL_POP  1
#define MAIL_IMAP 2

int mail_open_server(char *address, int port, int type);

int mail_get_count(void);

nxmail_header_t *mail_fetch_header(int message);
char *mail_fetch_message(int message);

int mail_close_server(void);

#endif

--- NEW FILE: nanomail.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef NANOMAIL_H
#define NANOMAIL_H

#include <FL/Fl_Browser.H>

void mlist_register_widget(Fl_Browser * msg);
void mlist_clear();
void mlist_add(char *from, char *date, char *subject);

#endif

--- NEW FILE: settings.cxx ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

extern "C"
{
#include <par/pardb.h>
}


#include "settings.h"

const char *defaultKeywords[] = {
    "server", "port", "username", "password",
    "smtpserver", "smtpname"
};

const char *defaultValues[] = {
    "localhost", "110", "", "",
    "localhost", ""
};

const char *defaultAccounts[] = { "Work", "Home", "Other" };

void
mailSettings::add_new_account(char *name)
{
    struct setAccount *a;

    if (_accounts == 0) {
	_accounts = new struct setAccount;
	a = _accounts;
    } else {
	a = _accounts;
	while (a->next)
	    a = a->next;
	a->next = new struct setAccount;
	a = a->next;
    }

    bzero(a, sizeof(struct setAccount));

    for (int i = 0; i < _count; i++) {
	strncpy(a->values[i], defaultValues[i], 30);
	a->saved[i] = 1;
    }

    strcpy(a->name, name);
    a->next = 0;

    _acount++;
}

struct setAccount *
mailSettings::get_account(char *name)
{
    struct setAccount *a = _accounts;

    while (a) {
	if (!strcmp(name, a->name))
	    return (a);

	a = a->next;
    }

    return (0);
}

void
mailSettings::set_temp_value(char *account, char *keyword, const char *value)
{
    int i;
    struct setAccount *a = get_account(account);

    if (!a)
	return;

    for (i = 0; i < _count; i++) {
	if (!strncmp(keyword, keywords[i], strlen(keywords[i]))) {
	    bzero(a->tempvalues[i], 31);

	    if (strlen(value))
		strncpy(a->tempvalues[i], value, 30);

	    a->saved[i] = 0;
	}
    }
}

int
mailSettings::confirm_account_changes(char *account)
{
    int i;
    int changed = 0;
    struct setAccount *a = get_account(account);

    if (!a)
	return (0);

    for (i = 0; i < _count; i++) {
	if (a->saved[i])
	    continue;

	changed |= set_value(account, keywords[i], a->tempvalues[i]);
	strcpy(a->tempvalues[i], "");
    }

    return (changed);
}

void
mailSettings::reject_account_changes(char *account)
{
    int i;
    struct setAccount *a = get_account(account);

    if (!a)
	return;

    for (i = 0; i < _count; i++) {
	strcpy(a->tempvalues[i], "");
	a->saved[i] = 1;
    }
}

void
mailSettings::reject_all_changes()
{
    int i;

    for (i = 0; i < _acount; i++)
	reject_account_changes(get_account_name(i));
}

int
mailSettings::confirm_all_changes()
{
    int i;
    int changed = 0;

    for (i = 0; i < _acount; i++)
	changed |= confirm_account_changes(get_account_name(i));

    return (changed);
}

int
mailSettings::set_value(char *account, char *keyword, const char *value)
{
    int i;
    struct setAccount *a = get_account(account);

    if (!a)
	return (0);

    for (i = 0; i < _count; i++) {
	if (!strncmp(keyword, keywords[i], strlen(keywords[i]))) {
	    /* Don't do anything if the setting hasn't changed */
	    a->saved[i] = 1;

	    if (strcmp(a->values[i], value)) {
		bzero(a->values[i], 31);
		strncpy(a->values[i], value, 30);
		return (1);
	    } else
		return (0);	/* No change */
	}
    }

    return (0);
}

char *
mailSettings::get_value(char *account, char *keyword)
{
    int i;

    struct setAccount *a = get_account(account);
    if (!a)
	return (0);

    for (i = 0; i < _count; i++) {
	if (!strncmp(keyword, keywords[i], strlen(keywords[i]))) {
	    if (a->saved[i] == 0)
		return (a->tempvalues[i]);
	    else
		return (a->values[i]);
	}
    }

    return (0);
}

int
mailSettings::load_settings(void)
{

    char parent[32];
    char child[64];

    int ret, sret, err;

    char *pardb = db_getDefaultDB();
    db_handle *handle = 0;

    if (!pardb) {
	fprintf(stderr, "ERROR:  Couldn't open the PAR database\n");
	return -1;
    }

    handle = db_openDB(pardb, PAR_DB_MODE_RDONLY);
    if (!handle) {
	fprintf(stderr, "ERROR:  Unable to read the database (%d)\n",
		pardb_errno);
	return -1;
    }

    /* Load each account */

    snprintf(parent, sizeof(parent) - 1, "nanomail.accounts");

    bzero(child, sizeof(child));

    ret = db_getFirstChild(handle, parent, child, sizeof(child) - 1);

    while (ret > 0) {
	char node[84];
	char account[64];
	char setting[64];
	char next[128];

	sprintf(node, "%s.%s.name", parent, child);

	bzero(account, sizeof(account));

	err = db_findNode(handle, node, &account, sizeof(account - 1), 0);

	if (err == -1) {
	    printf("Couldn't get the name for %s (%d)\n", node, pardb_errno);
	    goto next_account;
	}

	printf("Loaded account [%s]\n", account);

	if (!get_account(account))
	    add_new_account(account);

	/* Now, get the keywords */
	snprintf(node, sizeof(node) - 1, "%s.%s.settings", parent, child);

	bzero(setting, sizeof(setting));

	printf("Looking for children in %s\n", node);

	sret = db_getFirstChild(handle, node, setting, sizeof(setting) - 1);

	printf("got %d from db_getFirstChild\n", sret);

	while (sret > 0) {
	    char key[128];

	    char buffer[64];

	    sprintf(key, "%s.%s", node, setting);

	    err = db_findNode(handle, key, buffer, sizeof(buffer) - 1, 0);

	    if (err == -1) {
		printf("Couldn't get the keyword %s (%d)\n", key,
		       pardb_errno);
		goto next_keyword;
	    }

	    printf("Loaded keyword [%s] = [%s]\n", setting, buffer);

	    set_value(account, setting, buffer);

	  next_keyword:
	    strcpy(next, setting);
	    bzero(setting, sizeof(setting));

	    printf("Getting next peer of %s\n", next);

	    sret =
		db_getNextChild(handle, node, next, setting,
				sizeof(setting) - 1);
	    printf("Returned %d\n", sret);
	}

      next_account:
	strcpy(next, setting);
	bzero(child, sizeof(child));
	ret = db_getNextChild(handle, parent, next, child, sizeof(child) - 1);
    }

    db_closeDB(handle);
    return 0;
}

int
mailSettings::save_settings(void)
{
    struct setAccount *a;
    int acnt = 0;

    char *pardb = db_getDefaultDB();
    db_handle *handle = 0;

    if (!pardb) {
	fprintf(stderr, "ERROR:  Couldn't open the PAR database\n");
	return -1;
    }

    handle = db_openDB(pardb, PAR_DB_MODE_RW);

    if (!handle) {
	fprintf(stderr, "ERROR:  Unable to read the database (%d)\n",
		pardb_errno);
	return -1;
    }

    /* Save each account */

    for (a = _accounts; a; a = a->next, acnt++) {
	char name[128];

	sprintf(name, "nanomail.accounts.nxmail%d.name", acnt);

	if (db_addNode(handle, name, a->name, strlen(a->name), PAR_TEXT) ==
	    -1) {
	    fprintf(stderr, "ERROR - couldn't write account %s (%d)\n", name,
		    pardb_errno);
	    continue;
	}

	printf("Saved account [%s] to %s\n", a->name, name);

	for (int i = 0; i < _count; i++) {
	    sprintf(name, "nanomail.accounts.nxmail%d.settings.%s", acnt,
		    keywords[i]);

	    if (!a->values[i])
		continue;
	    if (!strlen(a->values[i]))
		continue;

	    printf("Saving [%s] {%d}\n", a->values[i], strlen(a->values[i]));

	    if (db_addNode
		(handle, name, a->values[i], strlen(a->values[i]),
		 PAR_TEXT) == -1) {
		fprintf(stderr, "ERROR - couldn't add keyword %s (%d)\n",
			name, pardb_errno);
		continue;
	    }
	}
    }

    db_closeDB(handle);
    return 0;
}

char *
mailSettings::get_account_name(int num)
{
    struct setAccount *a = _accounts;
    int i;

    for (i = 0; i < num; i++) {
	if (!a)
	    return (0);
	a = a->next;
    }

    if (!a)
	return (0);
    return (a->name);
}

mailSettings::mailSettings(void)
{
    /* Set the defaults */
    _accounts = 0;
    _acount = 0;

    _count = 6;

    for (int i = 0; i < _count; i++)
	strncpy(keywords[i], defaultKeywords[i], 30);

    /* Add the default accounts */

    for (int a = 0; a < 3; a++)
	add_new_account((char *) defaultAccounts[a]);
}

--- NEW FILE: mailengine.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef MAILENGINE_H
#define MAILENGINE_H

#include <string.h>
#include "nxmail.h"

typedef enum
{
    MAIL_POP3
}
MAILTYPE;

typedef enum
{
    MAIL_SUCCESS = 0,
    MAIL_OPEN_ERROR,
    MAIL_AUTH_ERROR,
    MAIL_SEND_ERROR
}
MAILERROR;

class mailEngine
{
  private:

    nxmail_stream * _stream;
    char _server[30];
    int _port;
    MAILTYPE _type;

  public:

      mailEngine(char *server, int port, MAILTYPE type);
     ~mailEngine();

    void reset_engine(char *, int, MAILTYPE);

    MAILERROR open_session(char *user, char *password);
    void close_session();

    int message_count();
    int active();

    nxmail_header_t *fetch_header(int);
    nxmail_body_t *fetch_message(int);
    int delete_message(int);

    void set_server(char *server)
    {
	strcpy(_server, server);
    }
    char *get_server(void)
    {
	return (_server);
    }

    void set_port(int port)
    {
	_port = port;
    }
    int get_port(void)
    {
	return (_port);
    }

    MAILERROR send_message(char *, int, nxmail_header_t *, char *, int);

    void set_type(MAILTYPE type)
    {
	_type = type;
    }
    MAILTYPE get_type(void)
    {
	return (_type);
    }
};

#endif

--- NEW FILE: ui.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef UI_H
#define UI_H

#include <signal.h>

#include <FL/Fl.H>

#include <nxbox.h>
#include <nxapp.h>
#include <nxwindow.h>
#include <nxbutton.h>
#include <nxmultilineinput.h>
#include <nxmultilineoutput.h>
#include <nxmenubutton.h>
#include <nxscroll.h>
#include <nxbrowser.h>
#include <nxsecretinput.h>

#include "mailengine.h"
#include "settings.h"

#define APP      "Email"
#define ABOUT    "About Email"
#define EMAIL_DB "email"
#define CAT_DB   "email_cat"
#define ACCT_DB  "email_acct"
#define CAT_NUM  4

class NxMail:public NxApp
{

    ////////////////////////////////////////////////////////////////////////////////
    // Instance Variables

  private:
    // Global Access Poin
    static NxMail *_inst;

    // Email Engine
    mailSettings *settings;
    mailEngine *engine;
    int current_account;

    // Database
    NxDb *db;

    // Windows
    NxWindow *containerWindow;
    NxPimWindow *mainWindow;
    NxPimWindow *editorWindow;
    NxPimWindow *settingsWindow;
    NxPimWindow *viewWindow;

    // mainWindow widgets
    NxOutput *l_Status;
    char statusBuffer[50];
    NxBrowser *m_List;
    NxMultilineOutput *m_View;

    // editorWindow widgets  
    NxInput *i_To;
    NxInput *i_CC;
    NxInput *i_Subject;
    NxMultilineInput *i_Message;

    // viewWindow widgets
#ifdef NOTUSED
    MimeGroup *g_Mime;
#endif
    Fl_Browser *m_Mime;

    // settingsWindow widets
    int accountCount;
    Fl_Menu_Item *accountArray;
    NxInput *i_Server;
    NxInput *i_Name;
    NxSecretInput *i_Pass;
    NxInput *i_SMTPServer;
    NxInput *i_SMTPName;

    NxMenuButton *m_Accounts;
    NxBox *l_Account;
#ifdef NOTUSED
    NxInput *i_Port;
#endif
    Fl_Group *g_Radio;
    NxButton *b_IMAP;
    NxButton *b_POP3;

    ////////////////////////////////////////
    // Category Lists

    NxCategoryList *cat_list[CAT_NUM];
    static NxCategoryList *main_category;
    static NxCategoryList *editor_category;
    NxCategoryList *settings_category;
    static NxCategoryList *view_category;

    ////////////////////////////////////////////////////////////////////////////////
    // Messages

  public:

    ////////////////////////////////////////
    // Public Interface

      NxMail(int argc, char *argv[]);
      virtual ~ NxMail();
    static void exit_callback(Fl_Widget * fl, void *o);

    // Window Messages
    Fl_Window *GetMainWindow();
    void ShowDefaultWindow();

    // Global Access Point
    static NxMail *Inst();

    // Email engine
    char *EngineGetSettings(char *szSetting);
    MAILERROR EngineOpenSession();
    void EngineCloseSession()
    {
	engine->close_session();
    }
    MAILERROR EngineSendMessage(char *server, int port,
				nxmail_header_t * header, char *body,
				int size);
    int EngineGetMsgCount()
    {
	return engine->message_count();
    }
    nxmail_header_t *EngineFetchHeader(int m)
    {
	return engine->fetch_header(m);
    }
    nxmail_body_t *EngineFetchMsg(int m)
    {
	return engine->fetch_message(m);
    }
    int EngineDeleteMsg(int m)
    {
	return engine->delete_message(m);
    }

    // mainWindow
    static void MainSetCategory(char *szCat);
    void MainSetStatus(const char *status);
    Fl_Browser *MainGetMList()
    {
	return m_List;
    }
    void MainShowWindow();

    // editorWindow
    void EditorClearFields();
    void EditorSetFields(char *to, char *cc, char *subject);
    void EditorIndentText(char *str);
    void EditorShowWindow();
    const char *EditorGetTo()
    {
	return i_To->value();
    }
    const char *EditorGetCC()
    {
	return i_CC->value();
    }
    const char *EditorGetSubject()
    {
	return i_Subject->value();
    }
    const char *EditorGetMsg()
    {
	return i_Message->value();
    }
    int EditorGetMsgSize()
    {
	return i_Message->size();
    }

    // settingsWindow
    void SettingsUpdateFields();
    void SettingsUpdateValues(int);
    void SettingsShowWindow();

    // viewerWindow
    void ViewerShowWindow();
    NxMultilineOutput *ViewerGetMView()
    {
	return m_View;
    }
    Fl_Browser *ViewerGetMimeWidget()
    {
	return m_Mime;
    }
    static void ViewerReplyMsgCB(Fl_Widget * fl, void *o);
    static void ViewerReplyAllMsgCB(Fl_Widget * fl, void *o);
    static void ViewerReplyFwdMsgCB(Fl_Widget * fl, void *o);

#ifdef NOTUSED
    void ViewerShowMimeWidget();
    void ViewerHideMimeWidget();
#endif

  private:
    void MakeMainWindow();
    void MakeEditorWindow();
    void MakeSettingsWindow();
    void MakeViewWindow();
    void CloseNanoMail(int signal);

    // Database messages
    char *CatRecord(int catid, string cat_name);

    // FLNX-Colosseum IPC messages
    virtual void ClientIPCHandler(int fd, void *o, int ipc_id = -1);
    void ExecuteSearch(int ipc_id, char *searchStr, int width);

    // mainWindow messages
    static void MainCloseCB(Fl_Widget * fl, void *o);

    // editorWindow messages
    static void EditorSendCB(Fl_Widget * fl, void *o);
    static void EditorCancelCB(Fl_Widget * fl, void *o);

    // viewerWindow messages
    static void ViewerAccountCB(Fl_Widget * fl, void *o);
    static void ViewerDeleteMsgCB(Fl_Widget * fl, void *o);
    static void ViewerSaveMsgCB(Fl_Widget * fl, void *o);
    static void ViewerViewMsgCB(Fl_Widget * fl, void *o);
    static void ViewerCloseCB(Fl_Widget * fl, void *o);

    // settingsWindow messages
    static void SettingsSaveCB(Fl_Widget * fl, void *o);
    static void SettingsCancelCB(Fl_Widget * fl, void *o);
    static void SettingsAccountCB(Fl_Widget * fl, void *o);

    ////////////////////////////////////////
    // Category list callbacks

    static void ChangeCatCB(Fl_Widget * fl, void *o);
    static void ChangeAcctCB(Fl_Widget * fl, void *o);

};

#ifdef NOTUSED

class MimeGroup:public Fl_Group
{
  private:

    NxButton * b_Save;
    NxButton *b_View;

    static void button_callback(Fl_Widget * widget, void *win);

  public:

      Fl_Browser * m_Mime;
      MimeGroup(int, int, int, int);
};

#endif // NOTUSED
#endif // UI_H

--- NEW FILE: mime.cxx ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#include <string.h>
#include "mime.h"

static struct
{
    char mimetype[50];
    MIMESUPPORT supported;
}
supported_mime[] =
{
    {
    "application/octet-stream", MIME_SAVE}
    ,				/* Save programs externally */
    {
    "application/x-gzip", MIME_SAVE}
    , {
    "message/delivery-status", MIME_TEXT}
    , {
    "message/http", MIME_TEXT}
    , {
    "message/partial", MIME_TEXT}
    , {
    "message/rfc822", MIME_TEXT}
    , {
    "multipart/report", MIME_TEXT}
    , {
    "text/plain", MIME_TEXT}
    , {
    "text/rfc822-headers", MIME_TEXT}
    , {
    "text/html", MIME_TEXT}
    , {
    "%%%", MIME_NOT_SUPPORTED}
};

MIMESUPPORT
check_mime_support(char *mimestr)
{
    int count = 0;

    while (1) {
	if (!strcmp(supported_mime[count].mimetype, "%%%"))
	    return (MIME_NOT_SUPPORTED);

	if (!strcmp(supported_mime[count].mimetype, mimestr))
	    return (supported_mime[count].supported);

	count++;
    }
}

--- NEW FILE: db_defs.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef _DB_DEFS_H_
#define _DB_DEFS_H_

////////////////////////////////////////////////////////////////////////////////
// Category list database

#define TEXT 25

// Category List
field catFields[] = {
    {'i', 1, 0}
    ,				// Field 0:catid
    {'c', TEXT, 0}
    ,				//       1:cat_name
    {0}
};

// Database
fildes catFile = {
    0, 0, 0,
    "dbf",
    2,
    &catFields[0]
};

#endif // _DB_DEFS_H_

--- NEW FILE: settings.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef SETTINGS_H
#define SETTINGS_H

#include <string.h>

struct setAccount
{
    char name[25];

    char values[6][31];
    char tempvalues[6][31];
    int saved[6];

    struct setAccount *next;
};

class mailSettings
{
  private:

    char keywords[6][31];

    struct setAccount *_accounts;
    int _acount;

    int _count;

    void add_new_account(char *name);
    struct setAccount *get_account(char *name);
    int set_value(char *account, char *keyword, const char *value);

  public:
      mailSettings(void);

    int load_settings();
    int save_settings();

    void set_temp_value(char *account, char *keyword, const char *value);

    int confirm_account_changes(char *account);
    void reject_account_changes(char *account);

    int confirm_all_changes();
    void reject_all_changes();

    char *get_value(char *account, char *keyword);

    int get_account_count(void)
    {
	return (_acount);
    }
    char *get_account_name(int num);
};

#endif

--- NEW FILE: Makefile ---
# apps/mp3/frontend/Makefile

TARGET_CXX=mail

SRC=${shell ls *.cxx}
OBJS=${SRC:.cxx=.o}

LIBS=-L../lib -lnxmail -lpixil-pim

ifeq ($(CONFIG_PAR),y)
LIBS+=-lpar
endif

ifeq ($(CONFIG_SYNC),y)
LIBS+=-lpixil-sync
endif

LIBS+=-lfltk -lflek

ifeq ($(CONFIG_NANOX),y)
LIBS+=-lnano-X 
endif

ifeq ($(CONFIG_X11),y)
LIBS+=-lX11
endif

ifeq ($(CONFIG_COLOSSEUM),y)
LIBS+=-lipc
endif

INCLUDES=-I../lib

include $(BASE_DIR)/Rules.make


--- NEW FILE: menu_defs.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef _MENU_DEFS_H_
#define _MENU_DEFS_H_

////////////////////////////////////////////////////////////////////////////////
// Menu Definitions

Fl_Menu_Item mainMenuItems[] = {

    {"Edit", 0, 0, 0, FL_SUBMENU}
    ,
//  { "Keyboard",0, NxApp::keyboard_callback},
    {"Settings...", 0, (Fl_Callback *) do_settings_callback, 0,
     FL_MENU_DIVIDER}
    ,
    {"Exit Mail", 0, NxMail::exit_callback}
    ,
    {0}
    ,

    {"Options", 0, 0, 0, FL_SUBMENU}
    ,
    {ABOUT, 0, NxApp::show_about}
    ,
    {0}
    ,

    {0}
};


Fl_Menu_Item editorMenuItems[] = {

    {"Edit", 0, 0, 0, FL_SUBMENU}
    ,
    {"Undo"}
    ,
    {"Cut"}
    ,
    {"Copy"}
    ,
    {"Paste", 0, 0, 0, FL_MENU_DIVIDER}
    ,
//  { "Keyboard",0, NxApp::keyboard_callback},
    {"Exit Mail", 0, NxMail::exit_callback}
    ,
    {0}
    ,

    {"Options", 0, 0, 0, FL_SUBMENU}
    ,
    {ABOUT, 0, NxApp::show_about}
    ,
    {0}
    ,

    {0}
};


Fl_Menu_Item settingsMenuItems[] = {

    {"Edit", 0, 0, 0, FL_SUBMENU}
    ,
    {"Undo"}
    ,
    {"Cut"}
    ,
    {"Copy"}
    ,
    {"Paste", 0, 0, 0, FL_MENU_DIVIDER}
    ,
//  { "Keyboard",0, NxApp::keyboard_callback},
    {"Exit Mail", 0, NxMail::exit_callback}
    ,
    {0}
    ,

    {"Options", 0, 0, 0, FL_SUBMENU}
    ,
    {ABOUT, 0, NxApp::show_about}
    ,
    {0}
    ,

    {0}
};

Fl_Menu_Item viewMenuItems[] = {

    {"Actions", 0, 0, 0, FL_SUBMENU}
    ,
    {"Reply", 0, NxMail::Inst()->ViewerReplyMsgCB}
    ,
    {"Reply All", 0, NxMail::Inst()->ViewerReplyAllMsgCB}
    ,
    {"Forward", 0, NxMail::Inst()->ViewerReplyFwdMsgCB, 0, FL_MENU_DIVIDER}
    ,
    {"Exit Mail", 0, NxMail::exit_callback}
    ,
    {0}
    ,

    {"Edit", 0, 0, 0, FL_SUBMENU}
    ,
    {"Undo"}
    ,
    {"Cut"}
    ,
    {"Copy"}
    ,
    {"Paste"}
    ,
//  { "Keyboard",0, NxApp::keyboard_callback},
    {0}
    ,

    {"Options", 0, 0, 0, FL_SUBMENU}
    ,
    {ABOUT, 0, NxApp::show_about}
    ,
    {0}
    ,

    {0}
};

////////////////////////////////////////////////////////////////////////////////
// About dialog box

about about_email = {
    "About Email",
    "(c) 2001, Century Software.",
    "jeffm at censoft.com",
    "08/24/01",
    "1.0"
};

#endif // _MENU_DEFS_H_

--- NEW FILE: pixmap.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef PIXMAP_H
#define PIXMAP_H

char *image_email_cancel[] = {
    "32 18 -32 1",
    "!\217\262l\"[oH#\330\353\304$\366\366\366%\240\307u&*4 \'\231\231\231(IZ8)\
\321\321\321*\271\327\226+\307\346\251,\313\344\262-\323\347\275.\254\323\204/\
\335\360\311" "0|\234\\1\260\327\213" "2\301\336\243" "3\272\341\225" "4m\210S5r\
\215W6g\200K76A+8\250\315\203"
	"9\317\357\262:\341\363\317;y\220`<\302\347\236=\
UUU>\277\277\277?\200\200\200@\352\352\352",
    "$#///############////:::://99$$$",
    "$-###----------#####//////998)@$",
    "$,---,,,,,,,,,,,,,---####9+1!\')$",
    "@2,,,2**2*2222222+++++999<1!4\'>@",
    "@***;&70.....111111*33<<<84(\"?>@",
    "@**;(%!&!%008%!!!.1!813!%!\"7(?>@",
    "@**7%8%%%&\"765&\"&!(\"&%\"\"76\"7(?>@",
    "@**&1%%%%!\"&\"0\"%\"0&.8%&\"\"&\"7(?>@",
    "@**\"\"8%\"6&56\"0\".\"0&1!0&31;\"7(?>@",
    "@1..(&&7!&&&(6(!\"4\"&&!\"&&\"(&(?>@",
    "@8%!0466666464444545455;6\"(77?>@",
    "@%0;6((((((((((((((((((((7777?>@",
    "@06\"7&&&&&&&&&&&&&&&&&7&7&7&7?>@",
    "@4(&&&&&&&&&&&&&&&&&&7&7&7&77?>@",
    "@>\'\"=========================\'>@",
    "$)\'\'?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\'\')$",
    "$@)>>>>>>>>>>>>>>>>>>>>>>>>>))@$",
    "$$$@@@@@@@@@@@@@@@@@@@@@@@@@@$$$"
};


char *image_email_savesmall[] = {
    "32 18 -31 1",
    "!l\207Q\"\330\353\304#\366\366\366$IZ8%^sI&\242\312w\'\271\327\226((2\36)\
\231\231\231*\321\321\321+\306\347\247,\254\322\205-\313\344\262.\323\347\275/\
\226\266x0\261\326\214" "1\335\360\311" "2\301\336\243" "3\274\343\227" "44?)5\
\227\274o6\214\262g7\215\251t8y\224^9\317\357\262:\341\363\317;\205\244"
	"b<UUU\
=\277\277\277>\200\200\200?\352\352\352",
    "#\"111\"\"\"\"\"\"\"\"\"\"\"\"1111::::1199###",
    "#.\"\"\"..........\"\"\"\"\"11111199,*?#",
    "#-...-------------...\"\"\"\"9+07)*#",
    "?2---2\'\'2\'2222222++++-999+07!)=?",
    "\?\'\'\'\',&$4%,,,00000\'\'333+3,7!%>=?",
    "\?\'\'\',&%%&%%&68&&5,&50/&30/8%$>=?",
    "\?\'\'0,&84%6&!4%(,(,$6$%480/8%$>=?",
    "\?\'00,&&6%(%&!$(&$540(%%40/8%$>=?",
    "\?\'\'\',&46&5(%%;(,8$%,(03/0/8%$>=?",
    "\?0,,&58(((8!(((;5(;5%((!/;!<$>=?",
    "\?&&5;!!!!%!!!%!!!!!!!!88!%$44>=?",
    "\?5;!%$$$$$$$$$$$$$$$$$$$$4444>=?",
    "\?;!%4((((((((((((((4(44444444>=?",
    "\?!$(((((((((((((((((4(4(44444>=?",
    "\?=)%<<<<<<<<<<<<<<<<<<<<<<<<<)=?",
    "#*))>>>>>>>>>>>>>>>>>>>>>>>>))*#",
    "#?*=========================**?#",
    "###?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?###"
};


char *image_email_send[] = {
    "32 18 -32 1",
    "!l\207Q\"\330\353\304#\366\366\366$\242\313w%]qI&HY7\'\271\327\225(\231\231\
\231)*4 *\324\324\324+\307\347\251,\254\322\205-\313\343\262.\323\347\275/\
\261\326\214" "0\225\265v1\334\360\311" "2\300\336\242" "3\273\342\226" "4\230\
\276r5x\224]64?)7\207\254" "e8\215\251t9\317\356\262:\341\363\317;\203\242"
	"b<\
\215\263g=UUU>\277\277\277?\200\200\200@\352\352\352",
    "#\"111\"\"\"\"\"\"\"\"\"\"\"\"1111::::1199###",
    "#.\"\"\"..........\"\"\"\"\"11111199,*@#",
    "#-...-------------....\"1\"9+/8(*#",
    "@----2\'2\'22222222+++++99++/8!(>@",
    "@\'\'\'\',$&)%,,,//////\'333%3,8!%?>@",
    "@\'\'\',$%%$%%$45$,7$;//406/05%&?>@",
    "@\'\'/,$56%<$<)%),)&&&46&)/05%&?>@",
    "@\'//,$$<%)%%&%);),,6%;3),05%=?>@",
    "@\'\'\',$6<$4)%%$<46,,6%!/)/05%&?>@",
    "@/,,$45)))57)))4)44)0)))0;!%&?>@",
    "@$$<;!!!!%!!!!!!!!!!!55!!%&66?>@",
    "@475%&&&&&&&&&&&&&&&&&&&&6666?>@",
    "@;!&&)))))))))))))))6)6666666?>@",
    "@!&6))))))))))))))))))6)6)666?>@",
    "@>(%========================%(>@",
    "#*((?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?((*#",
    "#@*>>>>>>>>>>>>>>>>>>>>>>>>>>*@#",
    "###@@@@@@@@@@@@@@@@@@@@@@@@@@###"
};

char *image_email_close[] = {
    "32 32 -32 1",
    "!\245\261\316\"lx\227#\226\250\332$\366\366\366%\234\251\311&\245\266\350\'\
\262\276\336(\324\324\324){\212\261*\322\331\354+\206\224\273,\',7-KUm.\313\
\323\350/\211\234\314" "0\203\225\305" "1\216\235\305" "2\305\322\366" "3\206\231\
\310" "4\300\312\344" "5\217\242\324" "6\327\337\364" "7\212\236\321"
	"8DK^99 at Q:dkz\
;Zd\177<\236\257\337=TTT>\277\277\277?\177\177\177@\352\352\352",
    "$*66**************66666666662$$$",
    "$****..........******6666622&(@$",
    "$4.(.44444444444.4..2.***22!)%($",
    "@4444\'\'\'\'\'\'\'\'\'\'\'\'\'4\'442224<+\"?>@",
    "@!\'\'!%%%%%%#%#<<<<<&&&\'\'\'<)\"-?>@",
    "@!!!%113////7555####<&&&&+\";8?>@",
    "@!!!%13333///7755###<<&&<1\";8?>@",
    "@!!!%133333//77555##<<&&<+\";8?>@",
    "@!!!%1003333//7755##<<&&<+\";8?>@",
    "@!!%%10000333/7755###<&&<+\";8?>@",
    "@!!%%10000333//7555##<&&<+\";8?>@",
    "@!!%%3;,,\"083377755##<<&<+\";8?>@",
    "@!!%%;9)),),33\"075\"0#</+<+\";8?>@",
    "@!!%%,)0000,0,-,)889\"\"9--+\";8?>@",
    "@!!%%,00000,\"87;-8,-/,;-,+\";8?>@",
    "@!!%%--00--,\"93;-;);993&)+\";8?>@",
    "@!!%%39,,80,38,,0;,,;),,;+\";8?>@",
    "@!!%%10+)0033/775555#<<<<+\";8?>@",
    "@!!%%1003033//7755###<&&<+\";8?>@",
    "@!!!%1003333/77555##<<&&<+\";8?>@",
    "@!!!%13333///77555##<<&&<1\";8?>@",
    "@!!!%13333///7755###<<&&<+\";8?>@",
    "@!!!%113////75555###<&&&<1\";8?>@",
    "@!!%1+))))))))+++++3115%1):-9?>@",
    "@%1+):;;;;;;:;;:;:\":\"\"\"\":;89,?>@",
    "@1):-899998988888888888-89,,9?>@",
    "@):-9,,,,,,,,,,,,,,,,,,,,,,9,?>@",
    "@:8,,,,,,,,,,,,,,,,,,,,,,9,,9?>@",
    "@>?:========================:?>@",
    "$(!?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>($",
    "$@((>>>>>>>>>>>>>>>>>>>>>>>>>(@$",
    "$$$@@@@@@@@@@@@@@@@@@@@@@@@@@$$$"
};

char *image_email_delete[] = {
    "32 32 -32 1",
    "!\205\223\273\"\205\230\307#mx\230$\225\247\332%\366\366\366&\244\266\350\'\
\266\303\347(&*5)\324\324\324*x\207\255+\244\263\336,KUn-\232\250\314.\322\
\331\352/\313\323\350" "0\246\262\316" "1\304\321\365" "2\301\313\343" "3\217\242\
\324" "4\322\333\363" "5BHZ6\260\274\332" "7dkz8\213\235\313"
	"9\235\257\336:Zd\
\177;\242\256\311<\331\340\363=TTT>\277\277\277?\177\177\177@\352\352\352",
    "%.<<............444<<<<<<<441%%%",
    "%....//////////.....44<<<411+)@%",
    "%2///222222222222/1///44411+!;)%",
    "@2222666666666\'\'\'\'\'\'21211\'+!7?>@",
    "@0660;------$-999+++&&\'\'\'9!#,?>@",
    "@000-8\"\"888883333$$99+&&+!#:5?>@",
    "@00;;8\"\"\"\"8888333$$$9+&&+\"#:5?>@",
    "@00;-8\"\"\"\"\"8888333$$99&&9!#:5?>@",
    "@00;-8!\"\"\"\"\"888333$$99&&+!#:5?>@",
    "@00;-8\"\"\"\"\"\"\"88333$$$9&&9!#:5?>@",
    "@0;;-8!\"\"\"\"\"\"888333$$9&&9!#:5?>@",
    "@0;*(((:\"\"\"\"\"#:8333$:9&&9!#:5?>@",
    "@00#,8*(*\"#*\"#,3**3!(\"9!\"!#:5?>@",
    "@0;#:\"!:,55(:#,:(55#(#,,5:#:5?>@",
    "@;0?,8\":5(,,(#,(,,(3($(:,(#:5?>@",
    "@0;#,8!5#(*\"##,(!3*3(9(99##:5?>@",
    "@00#(((5\",((:#,*((,3(::((:#:5?>@",
    "@0;;8\"!!\"\"\"\"\"\"\"8\"83$$$&&$!#:5?>@",
    "@00;-8\"\"\"\"\"\"\"88333$$$9&&9!#:5?>@",
    "@00;-8!\"\"\"\"\"883333$$99&&9!#:5?>@",
    "@00;-8\"\"\"\"\"8888333$$99&&+!#:5?>@",
    "@00;-8\"\"\"\"8883333$$$9&&&9!#:5?>@",
    "@000;88888888333$$$99+&&+8#:5?>@",
    "@0;-8!******!*!!!!!\"88--8*7,5?>@",
    "@-8!*7:::::::7:7:7#7####7:55(?>@",
    "@!*7:555555555555555555,5((((?>@",
    "@*755((((((((((((((((((((5(5(?>@",
    "@75(((((((((((((((((((((((((5?>@",
    "@)?7========================7?>@",
    "%);?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>)%",
    "%@))>>>>>>>>>>>>>>>>>>>>>>>>>)@%",
    "%%%@@@@@@@@@@@@@@@@@@@@@@@@@@%%%"
};


char *image_email_fwd[] = {
    "32 32 -32 1",
    "!\244\261\316\"\206\224\272#\231\253\333$jv\226%\366\366\366&\242\264\344\'\
\234\251\311(\262\276\336)\324\324\324*y\210\257+ISk,\322\331\352-(,7.\313\
\323\350/\215\235\305" "0\203\225\303" "1\304\321\365" "2\211\234\314" "3\206\230\
\310" "4\300\312\344" "5\220\243\326" "6\322\333\363"
	"7;BT8DK^9\213\236\321:ejw;\
\331\340\363<Zc~=TTT>\277\277\277?\177\177\177@\352\352\352",
    "%,;;,,,,,,,,,,,,666;;;;;;;661%%%",
    "%,,,,..........,,,,,66;;;611&)@%",
    "%4...444444444444.1...66611!\"\')%",
    "@4444(((((((((((((4(414114&\"$?>@",
    "@!>(!\'\'\'\'\'#\'####&&&&&((((#*$+?>@",
    "@!!!\'//322/2995555##&&&(&3$:8?>@",
    "@!!!\'/333322299555###&&&&/$<8?>@",
    "@!!!\'/3333322999555##&&&&\"$<8?>@",
    "@!!!\'/0033332299555##&&&#/$<8?>@",
    "@!!\'\'/0003333299955###&&&\"$<8?>@",
    "@!!\'\'/00003332299555#&&&#\"$<8?>@",
    "@!!\'\'/0$---732299555*<&&&\"$<8?>@",
    "@!!\'\'/0$+032$2*09*5$$<&&#\"$<8?>@",
    "@!!\'\'30<7<$*-27+*78+-<&&#\"$<8?>@",
    "@!!\'\'/0$-++*8$88+<-5$<&&#\"$<8?>@",
    "@!!\'\'30<+003$7<875-5$+&&&\"$<8?>@",
    "@!!\'\'/0$+0330-*<79<--<&&#\"$<8?>@",
    "@!!\'\'/00033330399555##&&#\"$<8?>@",
    "@!!\'\'/00033322999555#&&&&3$<8?>@",
    "@!!!\'/0033322299555##&&&&\"$<8?>@",
    "@!!!\'/3333322999555##&&&#/$<8?>@",
    "@!!!\'/333322299555###&&&&\"$:8?>@",
    "@!!!\'//3/222995555##&&&(&/$<8?>@",
    "@!!\'/\"*******\"\"\"\"003//55/*:+7?>@",
    "@\'/\"*$<<<<<<<<<:<$:$$$$$$<87-?>@",
    "@/*$+877778788888788888+77--7?>@",
    "@*:=7---------------------7--?>@",
    "@:8-------------------------7?>@",
    "@>?:========================:?>@",
    "%)!?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>)%",
    "%@))>>>>>>>>>>>>>>>>>>>>>>>>>)@%",
    "%%%@@@@@@@@@@@@@@@@@@@@@@@@@@%%%"
};


char *image_email_getmail[] = {
    "32 32 -32 1",
    "!\207\231\307\"kw\230#\232\253\334$\366\366\366%x\207\255&\244\266\347\'\230\
\247\313(\266\303\347)\324\324\324*MWq+$(4,\240\261\336-\322\331\352.\204\223\
\276/\313\323\350" "0\246\262\317" "1\304\321\365" "2\301\313\343" "3\322\333\363" "\
4\212\234\314" "5FL_6\260\274\332" "7\217\242\324"
	"8/3 at 9\\e~:\241\255\312;\331\
\340\363<<CV=TTT>\277\277\277?\177\177\177@\352\352\352",
    "$-;;------------333;;;;;;;331$$$",
    "$----//////////-----33;;;311,)@$",
    "$2///222222222222/1///333110.:)$",
    "@2222666666666((((((21211(&.\"?>@",
    "@0660:\'\'\'\'\'\'###,,,,&&&(((,%\"*?>@",
    "@000:4!!444447777\'##,&&&,.\"95?>@",
    "@00::4!!!!44447777###,&&,!\"95?>@",
    "@00:\'4!!!98+*4477779#,&&,.\"95?>@",
    "@00:\'4.!9<.!**4!\"74+.,&&,!\"95?>@",
    "@00:\'4.!8%!!!4%+*+.+9#&&,.\"95?>@",
    "@0::\'4..+!!<++*<*+\"+#,&&,.\"95?>@",
    "@0::\'!..*5!!.+*94.!+##&&#.\"95?>@",
    "@0::\'!..!5+++\".+++785#&&,.\"95?>@",
    "@0::\'!...!.!.!44777###&&#.\"95?>@",
    "@0::\'4.!.!!!!4447777##&&,.\"95?>@",
    "@0::\'!.\"+%!\"+!44779%9.,&#.\"95?>@",
    "@0::\'4.9+*!8+44\"%7.7*\"&&,.\"95?>@",
    "@00:\'!.\"<8!8+!+*89*\"*%&&#.\"95?>@",
    "@00:\'4!9*+\"<+4%*+**\"*%&&,.\"95?>@",
    "@00:\'4.\"5*<\"+4+\"9**\"9%,&,.\"95?>@",
    "@00:\'4!9*\"+4+48+85*\"*%&&,!\"95?>@",
    "@00::4!!!!!!447777##,,&&,.\"95?>@",
    "@000\'\'!!444447777###,&&&,!\"95?>@",
    "@0:\'\'.%%%%%%.......!44\'\'4%9*<?>@",
    "@\'4.\"\"99999999999\"9\"\"\"\"\"\"95<8?>@",
    "@!%\"*5<<<<<<<<555<555555<8888?>@",
    "@?9=<+++++++++++++++++8888888?>@",
    "@958+++++++++++++8+8888888888?>@",
    "@)?9========================9?>@",
    "$):?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>)$",
    "$@))>>>>>>>>>>>>>>>>>>>>>>>>>)@$",
    "$$$@@@@@@@@@@@@@@@@@@@@@@@@@@$$$"
};


char *image_email_init[] = {
    "32 32 -32 1",
    "!\206\224\272\"\245\261\316#\226\250\332$jv\227%\366\366\366&\244\266\347\'\
\234\251\311(\262\276\336)\324\324\324*y\210\257+\322\331\352,(,6-\313\323\
\350.ISl/\203\224\303" "0\215\235\305" "1\304\321\365" "2\211\234\314" "3\206\230\
\310" "4\217\242\324" "5\300\312\344" "6\322\333\363" "7\236\257\336"
	"8CI[9ejw:\
\212\236\321;\331\340\363<Zd}=TTT>\277\277\277?\177\177\177@\352\352\352",
    "%+;;++++++++++++666;;;;;;;661%%%",
    "%++++----------+++++66;;;611&)@%",
    "%5---555555555555-1---66611\"!\')%",
    "@5555(((((((((((((5(515115&!9?)@",
    "@\">(\"\'\'\'\'\'\'#\'#77&7&&&&(((#!$.?>@",
    "@\"\"\"\'0032222:4444###7&&&&!$<8?>@",
    "@\"\"\"\'03333222::444##77&&70$<8?>@",
    "@\"\"\"\'03333322::444##77&&7!$98?>@",
    "@\"\"\"\'0//333322::44##77&&70$<8?>@",
    "@\"\"\'\'0/3/33332::44###7&&7!$<8?>@",
    "@\"\"\'\'0////33322:444##7&&7!$<8?>@",
    "@\"\"\'\'0///$<332::84<##7&&7!$<8?>@",
    "@\"\"\'\'0///$./*$*:**,/##&&7!$<8?>@",
    "@\"\"\'\'3///<.$,.,*,$,$#77&7!$<8?>@",
    "@\"\"\'\'0///$.<83.$,:,4#7&&7!$<8?>@",
    "@\"\"\'\'3///<.$.3.$,:,4#7&&7!$<8?>@",
    "@\"\"\'\'0///$.$.2.$,:,<#77&7!$<8?>@",
    "@\"\"\'\'0//////3::::4:4#7&&7!$<8?>@",
    "@\"\"\'\'0//333332::44###7&&7!$<8?>@",
    "@\"\"\"\'0/333322:::44##77&&7!$<8?>@",
    "@\"\"\"\'03333322::444##77&&70$<8?>@",
    "@\"\"\"\'03333222::44###7&&&7!$98?>@",
    "@\"\"\"\'0030222:4444###7&&(70$<8?>@",
    "@\"\"\'0!*******!!!!//3004#0*9.8?>@",
    "@\'0!*$<<<<<<<<<<<$9$$$$$$<88,?>@",
    "@0*$.888888888888888888.8,,,,?>@",
    "@*988,,,,,,,,,,,,,,,,,,,,,,,,?>@",
    "@98,,,,,,,,,,,,,,,,,,,,,,,8,8?>@",
    "@)?9========================9?>@",
    "%)\'?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>)%",
    "%@))>>>>>>>>>>>>>>>>>>>>>>>>>)@%",
    "%%%@@@@@@@@@@@@@@@@@@@@@@@@@@%%%"
};


char *image_email_new[] = {
    "32 32 -32 1",
    "!\205\223\272\"\245\261\316#\226\250\332$kv\225%\366\366\366&\244\266\350\'\
\234\251\311(\262\276\336)\324\324\324*\'+5+x\207\255,\322\331\352-JTm.\313\
\323\350/\215\235\305" "0\204\225\303" "1\211\234\314" "2\304\321\365" "3\206\230\
\311" "4\300\312\344" "5\217\242\324" "6\322\333\363" "7\212\236\321"
	"8;BT9EK^:\\e\
~;\236\257\336<\331\340\363=TTT>\277\277\277?\177\177\177@\352\352\352",
    "%,<<,,,,,,,,,,,,666<<<<<<<662%%%",
    "%,,,,..........,,,,,66<<<622&)@%",
    "%4...444444444444.2...66622\"!\')%",
    "@4444(((((((((((((4(424224&!$?>@",
    "@\">(\"\'\'\'\'\'\'#\'#;;;;;&&&(((#!$-?>@",
    "@\"\"\"\'//311117555###;;&&&&0$:9?>@",
    "@\"\"\"\'/33331117755###;;&&;/$:9?>@",
    "@\"\"\"\'/303331177555##;;&&;!$:9?>@",
    "@\"\"\"\'/003333117755##;;&&;/$:9?>@",
    "@\"\"\'\'/000333317755###;&&;!$:9?>@",
    "@\"\"\'\'/0000333117555##;&&;0$:9?>@",
    "@\"\"\'\'/0$83383177755##;&&;!$:9?>@",
    "@\"\"\'\'/0:*:3*33++7+510;!&;0$:9?>@",
    "@\"\"\'\'30$8*3*398*$8!-8;*&;!$:9?>@",
    "@\"\"\'\'/0:-:-*0*--*:--9!-&;0$:9?>@",
    "@\"\"\'\'30$-38*0*07+589:8!&;!$:9?>@",
    "@\"\"\'\'/0:-0$*0-**:58:!*;&;0$:9?>@",
    "@\"\"\'\'/00003+0333755###;&;!$:9?>@",
    "@\"\"\'\'/003333377755###;&&;0$:9?>@",
    "@\"\"\"\'/003331177555##;;&&;!$:9?>@",
    "@\"\"\"\'/333331177555##;;&&;/$:9?>@",
    "@\"\"\"\'/33331117755###;&&&;!+:9?>@",
    "@\"\"\"\'////11175555###;&&&&!$:9?>@",
    "@\"\"\'/!++++++!!!!!003//5\'/+$-8?>@",
    "@\'/!+$:::::::::::$:$$$$$$:98*?>@",
    "@/+$-988888898999899999-8***8?>@",
    "@+:=8*********************8**?>@",
    "@:9*********************8***8?>@",
    "@)?:========================:?>@",
    "%)\'?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>)%",
    "%@))>>>>>>>>>>>>>>>>>>>>>>>>>)@%",
    "%%%@@@@@@@@@@@@@@@@@@@@@@@@@@%%%"
};


char *image_email_quit[] = {
    "32 32 -32 1",
    "!\244\261\316\"\206\224\272#\232\253\334$mx\230%\366\366\366&\243\264\345\'{\
\212\261(\234\251\311)\262\276\336*\324\324\324+\322\331\352,%)4-\313\323\350.\
KUo/\203\224\303" "0\215\235\305" "1\211\234\314" "2\304\321\365" "3\300\312\344" "\
4\220\242\325" "5\206\230\310" "6\322\333\363" "7\213\236\321"
	"8EL^9\\e~:<CU;\
\331\340\363<.3?=TTT>\277\277\277?\177\177\177@\352\352\352",
    "%+;;++++++++++++666;;;;;;;662%%%",
    "%++++----------+++++66;;;622&*@%",
    "%3---333333333333-2---66622!\"(*%",
    "@3333)))))))))))))3)323223&\"$?>@",
    "@!>)!((((((#(###&&&&&))))#\'$.?>@",
    "@!!!(0051111774444###&&)&5$98?>@",
    "@!!!(0555511177444###&&&&\"$98?>@",
    "@!!!(05555511777444##&&&&\"$98?>@",
    "@!!!(0//55551177444##&&&#\"$98?>@",
    "@!!((0/5/5555177444###&&&\"$98?>@",
    "@!!((0////5551177444##&&#\"$98?>@",
    "@!!((0///9<<91777448#9&&#\"$98?>@",
    "@!!((0//9:\'/:9/\'7\'5\'/,1&#\"$98?>@",
    "@!!((5//<\'5/\'<$.7.$,$,$&#\"$98?>@",
    "@!!((0//,/555,$.4.$<#,&&#\"$98?>@",
    "@!!((5//../...$:78$,#<&&#\"$98?>@",
    "@!!((0///:,,,./,<,$<4,9&#\"$98?>@",
    "@!!((0///55//$717444##&&&\"$98?>@",
    "@!!((0///5555177444###&&#\"$98?>@",
    "@!!!(0/555511777444##&&&&\"$98?>@",
    "@!!!(05555511174444##&&&#\"$98?>@",
    "@!!!(0555511177444###&&&&\"$98?>@",
    "@!!!(005011177444####&&)&0$98?>@",
    "@!!(0\"\'\'\'\'\'\'\'\"\"\"\"/\"500440\'9.:?>@",
    "@(0\"$$999999999999$9$$$$998:<?>@",
    "@0\'$.8:::::::8:88888888.8<<<<?>@",
    "@?98:,,,,,,,,,,,,,,,,,<<<<<<<?>@",
    "@98<,,,,,,,,,,,,,,<,<<<<<<<<<?>@",
    "@*?9========================9?>@",
    "%*(?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>*%",
    "%@**>>>>>>>>>>>>>>>>>>>>>>>>>*@%",
    "%%%@@@@@@@@@@@@@@@@@@@@@@@@@@%%%"
};

char *image_email_reply[] = {
    "32 32 -32 1",
    "!\205\227\307\"\206\224\272#kw\226$\225\247\332%\366\366\366&\230\247\313\'&*\
5(\267\304\346)\245\267\350*\324\324\324+z\211\260,\244\263\334-\322\331\353.I\
Sk/\313\323\350" "0\246\262\316" "1\306\323\366" "2\301\313\344" "3\217\242\324" "4\
\327\337\363" "5EK^6\260\274\331" "7\213\235\314" "8\235\257\337"
	"9ejw:<CU;\241\
\255\312<Zd~=TTT>\277\277\277?\177\177\177@\352\352\352",
    "%-44-------------444444444441%%%",
    "%----//////////------4444411,*@%",
    "%2/*/2222222222222///1---11,\";*%",
    "@(222666666666((((((22111(,\"9?>@",
    "@6660;&&&&$&$8;88,,))))((8\"#.?>@",
    "@000;7!7777773333$$88))),\"#<5?>@",
    "@00;;7!!!!7777333$$$88)),\"#<5?>@",
    "@00;&7\"!!!!7777333$$88))8\"#95?>@",
    "@00;&7!!!!!!777333$$88)),\"#<5?>@",
    "@00;&7\"!!!!!777733$$$8))8\"#<5?>@",
    "@0;;&7!!!!!!!777333$$8))8\"#<5?>@",
    "@0;;&#\'\'\'<!!!777333$.88)8\"#<5?>@",
    "@0;;&#.!+\'!!#+7!+#!$\'!$)!+#<5?>@",
    "@0;;&#:<<\'!:5\'<#\'.\'$\'+.)\'+#<5?>@",
    "@;0&&#\':\'#!\'..\'#:3.#\'8\'75\"#<5?>@",
    "@0;;&#5!:.!\'!!+#53:+\'8<5#\"#<5?>@",
    "@0;;&#.!!\'+.\'\'<#\'\':$\'8\"\'8\"#<5?>@",
    "@00;&!\"!!!!!!!!#.33$88<.$\"#<5?>@",
    "@00;&7!!!!!!!77+#3$$$8<88\"#<5?>@",
    "@00;&7\"!!!!!777333$$88))8\"#<5?>@",
    "@00;&7!!!!!7777333$$88)),!#<5?>@",
    "@00;;7!!!77777333$$$88))8\"#<5?>@",
    "@000;77!77777333$$$88,)),7#<5?>@",
    "@0;&&\"++++++\"+\"\"\"\"!!77&&7+9.:?>@",
    "@&&++9<<<<<<<<<<#<#9####9<5:\'?>@",
    "@\"+#.5:::::::555:555555.5:\'\':?>@",
    "@+95:\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\':\'\'?>@",
    "@95\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\':\'?>@",
    "@*?9========================9?>@",
    "%*;?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>*%",
    "%@**>>>>>>>>>>>>>>>>>>>>>>>>>*@%",
    "%%%@@@@@@@@@@@@@@@@@@@@@@@@@@%%%"
};


char *image_email_replyall[] = {
    "32 32 -32 1",
    "!\206\224\273\"kw\230#\204\227\307$\226\250\332%\366\366\366&&*5\'\230\247\
\314(z\211\260)\244\266\350*\267\304\346+\324\324\324,LVp-\244\263\334.\322\
\331\352/\313\323\350" "0\246\262\316" "1\305\322\366" "2\301\313\344" "3\323\334\
\363" "4EL_5<BT6\260\274\332" "7\213\235\312" "8[e\177"
	"9\217\241\324:\241\255\
\312;\331\341\363<\235\257\336=TTT>\277\277\277?\177\177\177@\352\352\352",
    "%.;;............333;;;;;;;331%%%",
    "%....//////////./...33;;;311-+@%",
    "%2///22222222222/2////.3311-!:+%",
    "@*2226666666666*****22111*-!\"?>@",
    "@6660:\'\'\'\'\'\'$$<<<--)))***<(\",?>@",
    "@000:77#77777999$$$$<)))-!\"84?>@",
    "@00::7##7#7777999$$$<<))<7\"84?>@",
    "@00:(&&&8#77777999$4<<))-!\"84?>@",
    "@00:\",#(&##\"(7#(\"#$&#$)9\'!\"84?>@",
    "@00:\"588&!54&8\"&,&$&(,<&\'!\"84?>@",
    "@0::\"&5&\"#&,,&\"594\"&$&74<!\"84?>@",
    "@0::\",!44#&##\"\"595(&<84\"<!\"84?>@",
    "@0::\",#!&(,&&8\"&&59&$(&)<!\"84?>@",
    "@0::\'7!#######\",799$$84<<!\"84?>@",
    "@0::\'##!######(\"999$$8$)<!\"84?>@",
    "@0::\'7!#######7#999$$<))<!\"84?>@",
    "@0::\'#!#####&\"#(88($$<<)<!\"84?>@",
    "@00:\'7#####8549\",,\"$$<))<!\"84?>@",
    "@00:\'7!####&#&#\",,\"$$<))<!\"84?>@",
    "@00:\'7####!&4&8\",,\"$<<))<!\"84?>@",
    "@00:\'7####44\"\"5\",,\"$<<))-!\"84?>@",
    "@00::7##7#&777&\",,\"<<)))<!\"84?>@",
    "@000:77777779999$$$$<-))-7\"84?>@",
    "@0:\'7!(((((((!!!!!##77\'\'7(8,5?>@",
    "@\'7!\"\"88888888888\"8\"\"\"\"\"\"845&?>@",
    "@!(\"8455555545444544444455&&5?>@",
    "@(845&&&&&&&&&&&&&&&&&&&&&&5&?>@",
    "@8=&&&&&&&&&&&&&&&&&&&&5&5&&5?>@",
    "@+?8========================8?>@",
    "%+:?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>+%",
    "%@++>>>>>>>>>>>>>>>>>>>>>>>>>+@%",
    "%%%@@@@@@@@@@@@@@@@@@@@@@@@@@%%%"
};

char *image_email_save[] = {
    "32 32 -32 1",
    "!\207\231\307\"\225\247\332#lx\227$\366\366\366%y\210\260&\244\266\350\'\230\
\247\313(\267\304\346)\324\324\324*\'+6+\244\263\334,\322\331\352-\205\224\
\275.LVr/\313\323\350" "0\246\262\316" "1\305\322\366" "2\301\313\344" "3\217\241\
\323" "4\323\334\363" "5\212\235\315" "6EL_7\260\274\332"
	"8\\e}9;BT:\241\255\312;\
\235\257\336<\331\341\363=TTT>\277\277\277?\177\177\177@\352\352\352",
    "$,<<,,,,,,,,,,,,444<<<<<<<441$$$",
    "$,,,,//////////,/,,,44<<<411+)@$",
    "$2///22222222222/2////,4411+-:)$",
    "@(2227777777777(((((22111(+-#?>@",
    "@7770:\'\'\'\'\"\'\";;;;++&&&(((;%#.?>@",
    "@000:5!!!5553533\"\"\";;+&&+-#86?>@",
    "@00::5!!!!5555333\"\"\";&&&+!#86?>@",
    "@00:\'5!!!!!5555333\"\";;&&;-#86?>@",
    "@00:\'5--!!!!555333\"\";;&&+-#86?>@",
    "@00:\'!!!!!!!!55333\"\"\";&&;-#86?>@",
    "@0::\'!---!!!!555333\"\";&&;-#86?>@",
    "@0::\'!%9*.-!!55533\"\"\";&&;-#86?>@",
    "@0::\'56.-..!%#-!%3!-\"%5&;-#86?>@",
    "@0::\'!8*.%!8*.*!*36%6.9#;-#86?>@",
    "@0::\'5!%.*.5.9*59%*3*.8*;-#86?>@",
    "@0::\'!*%-%*..#*-#9.\"*\"&-;-#86?>@",
    "@0::\'5#***#8***-5*-38**#;-#86?>@",
    "@00:\'!----!!!!!!333\"\"\";&;-#86?>@",
    "@00:\'!!!!!!!!55533\"\"\";&&;-#86?>@",
    "@00:\'5-!!!!!555333\"\";;&&;-#86?>@",
    "@00:\'5!!!!!555533\"\"\";;&&+-#86?>@",
    "@00::5!!!!5555333\"\"\";&&&;-#86?>@",
    "@000\'\'!!!5555333\"\"\";;+&&+!#86?>@",
    "@0:\'\'-%%%%%%-%-----!!33\'5%8.9?>@",
    "@\'5-##88888888888#8######869*?>@",
    "@!%#.699999996666966666699**9?>@",
    "@?8=9*********************9**?>@",
    "@86************************9*?>@",
    "@)?8========================8?>@",
    "$):?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>)$",
    "$@))>>>>>>>>>>>>>>>>>>>>>>>>>)@$",
    "$$$@@@@@@@@@@@@@@@@@@@@@@@@@@$$$"
};


char *image_email_view[] = {
    "32 32 -32 1",
    "!\245\261\316\"\206\224\272#\226\250\332$lx\227%\366\366\366&\245\266\350\'\
\234\251\311(\262\276\336)y\210\260*\324\324\324+\',6,\322\331\352-KUq.\313\
\323\350/\211\234\314" "0\215\235\305" "1\203\225\304" "2\304\321\365" "3\300\312\
\344" "4\217\242\324" "5\206\230\310" "6\322\333\363" "7EK^8\213\236\321"
	"9\\e~::@\
R;\236\257\336<\331\340\363=TTT>\277\277\277?\177\177\177@\352\352\352",
    "%,<<,,,,,,,,,,,,666<<<<<<<662%%%",
    "%,,,,..........,,,,,66<<<622&*@%",
    "%3...333333333333.2...66622!\"\'*%",
    "@3333(((((((((((((3(323223&\"$?>@",
    "@!>(!\'\'\'\'\'\'#\'#;;;;;&&&(((;)$-?>@",
    "@!!!\'005////8444####;&&&&\"$97?>@",
    "@!!!\'05555///8844###;;&&;0$97?>@",
    "@!!!\'055555//88444##;;&&;\"$97?>@",
    "@!!!\'0115555//8844##;;&&;\"$97?>@",
    "@!!\'\'01115555/8844###;&&;\"$97?>@",
    "@!!\'\'01111555//8844##;&&;\"$97?>@",
    "@!!\'\'0:111-99588844##;;&;\"$97?>@",
    "@!!\'\'0:$11+1)5))8)5#);/#;\"$97?>@",
    "@!!\'\'5$:1--9-9+7799)+#78;\"$97?>@",
    "@!!\'\'01+1+)$-+--+1:--)+&;\"$97?>@",
    "@!!\'\'517-+/9-+)8$8:71:9&;\"$97?>@",
    "@!!\'\'01$+-1$-$++-49:4+/&;\"$97?>@",
    "@!!\'\'011)1555855844###;&;\"$97?>@",
    "@!!\'\'01155555/8844###;&&;\"$97?>@",
    "@!!!\'011555//88844##;;&&;\"$97?>@",
    "@!!!\'055555///8444##;;&&;\"$97?>@",
    "@!!!\'05555///8844###;&&&;\"$97?>@",
    "@!!!\'005////88444###;&&&;0$97?>@",
    "@!!\'0\")))))))\"\"\"\"\"15004\'0)9-:?>@",
    "@\'0\"$$99999999999$9$$$$$$97:+?>@",
    "@0)$97::::7:7777777777777+++:?>@",
    "@?97:++++++++++++++++++++:+:+?>@",
    "@97+++++++++++++++++++++++++:?>@",
    "@*?9========================9?>@",
    "%*!?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?\?>*%",
    "%@**>>>>>>>>>>>>>>>>>>>>>>>>>*@%",
    "%%%@@@@@@@@@@@@@@@@@@@@@@@@@@%%%"
};

#endif

--- NEW FILE: main.cxx ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


/*
 UI.CXX

 User interface for nanomail
*/

#include <pixil_config.h>

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <getopt.h>

#include "nanomail.h"

#include "ui.h"
#include "mailengine.h"
#include "settings.h"

int exit_flag;

int
main(int argc, char **argv)
{
    NxMail mail(argc, argv);

    Fl_Window *w = mail.GetMainWindow();

    if (w->shown())
	mail.ShowDefaultWindow();

    while (!exit_flag) {

	if ((Fl::wait() == 0)) {

	    if (!mail.noguisearch_flag) {
		break;
	    }

	}

    }

}

--- NEW FILE: callbacks.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef CALLBACKS_H
#define CALLBACKS_H

typedef enum
{
    REPLY_SINGLE = 0,
    REPLY_ALL,
    REPLY_FORWARD
}
ReplyType;

void new_message_callback();
void reply_message_callback(ReplyType type);
void check_mail_callback();
void do_settings_callback();
void delete_message_callback();

void send_message_callback();
void get_message_callback();

void save_message_callback();
void view_message_callback();

void close_nanomail(int);

#endif

--- NEW FILE: mime.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef MIME_H
#define MIME_H

typedef enum
{
    MIME_NOT_SUPPORTED = 0,
    MIME_TEXT,
    MIME_SAVE,
    MIME_EXTERNAL,
}
MIMESUPPORT;

MIMESUPPORT check_mime_support(char *mimestr);

#endif

--- NEW FILE: callbacks.cxx ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#include <stdio.h>
#include <string.h>
#include <time.h>

#include "nxmail.h"
#include "callbacks.h"
#include "ui.h"
#include "mailengine.h"
#include "settings.h"

#include "actions.h"

static void
handle_mail_error(MAILERROR error)
{

    NxMail *inst = NxMail::Inst();

    char errorMsg[100];


    switch (error) {
    case MAIL_OPEN_ERROR:
	sprintf(errorMsg, "Couldn't talk to server %s!",
		inst->EngineGetSettings("server"));
	break;
    case MAIL_AUTH_ERROR:
	sprintf(errorMsg, "Couldn't authorize %s!",
		inst->EngineGetSettings("username"));
	break;

    case MAIL_SEND_ERROR:
	sprintf(errorMsg, "Couldn't send a message to %s",
		inst->EngineGetSettings("smtpserver"));
	break;
    default:
	return;
    }

    inst->MainSetStatus(errorMsg);

}

static int
get_message_number(Fl_Browser * mlist)
{
    int list = mlist->value();
    return ((int) mlist->data(list));
}

/* Various callbacks for the different windows */

void
new_message_callback()
{
    /* Just fire the editor */
    NxMail *inst = NxMail::Inst();
    inst->EditorClearFields();
    inst->EditorShowWindow();
}

void
reply_message_callback(ReplyType type)
{
    reply_to_message(type);
}

void
delete_message_callback()
{
    NxMail *inst = NxMail::Inst();

    char outmsg[100];

    MAILERROR r;

    sprintf(outmsg, "Deleting message from %s...",
	    inst->EngineGetSettings("server"));
    inst->MainSetStatus(outmsg);

    r = inst->EngineOpenSession();

    if (r != MAIL_SUCCESS) {
	handle_mail_error(r);
	return;
    }

    int msg = get_message_number(inst->MainGetMList());
    delete_message(msg);

    inst->MainSetStatus("");
    inst->EngineCloseSession();

    inst->MainShowWindow();
}

void
check_mail_callback()
{

    NxMail *inst = NxMail::Inst();

    char outmsg[100];

    MAILERROR r;

    sprintf(outmsg, "Getting mail from %s...",
	    inst->EngineGetSettings("server"));

    inst->MainSetStatus(outmsg);

    r = inst->EngineOpenSession();

    if (r != MAIL_SUCCESS) {
	handle_mail_error(r);
	return;
    }

    get_message_list();
    inst->EngineCloseSession();
}

void
do_settings_callback()
{

    NxMail *inst = NxMail::Inst();

    inst->SettingsUpdateFields();
    inst->SettingsShowWindow();

}

static void
build_addrlist(char *value, nxmail_addr_t * alist)
{
    int count = nxmail_count_addrstr(value);

    if (!count)
	return;

    count = nxmail_alloc_addrlist(alist, count);
    nxmail_build_addrlist(value, alist, count);
}

void
send_message_callback()
{

    NxMail *inst = NxMail::Inst();

    MAILERROR r;

    char outmsg[100];
    char addrstr[100];

    nxmail_header_t header;

    bzero(&header, sizeof(header));

    /* Get the to and cc lists */
    build_addrlist((char *) inst->EditorGetTo(), &header.to);
    build_addrlist((char *) inst->EditorGetCC(), &header.cc);

    /* Do the subject and the date */
    strcpy(header.subject, inst->EditorGetSubject());
    nxmail_parse_dateval(time(0), &header.date);

    bzero(addrstr, 100);

    /* Finally, construct the from address using the mail settings */
    sprintf(addrstr, "%s@%s", inst->EngineGetSettings("smtpname"),
	    inst->EngineGetSettings("smtpserver"));

    printf("The message is from %s <%d>\n", addrstr, strlen(addrstr));

    rfc822_parse_address(&header.from, addrstr);

    /* Ok, so we have the header, and we have the body. */
    /* lets light this candle */

    sprintf(outmsg, "Sending message to %s...",
	    inst->EngineGetSettings("smtpserver"));

    inst->MainSetStatus(outmsg);
    r = inst->EngineSendMessage(inst->EngineGetSettings("smtpserver"), 25,
				&header, (char *) inst->EditorGetMsg(),
				inst->EditorGetMsgSize());

    if (r != MAIL_SUCCESS) {
	handle_mail_error(r);
	//    return;
    } else
	inst->MainSetStatus("Message sent!");

    inst->MainShowWindow();

}

void
get_message_callback()
{

    if (Fl::event_clicks()) {
	NxMail *inst = NxMail::Inst();

	char messagestr[50];

	int msg = get_message_number(inst->MainGetMList());

	MAILERROR r;

	sprintf(messagestr, "Getting message %d...", msg);

	inst->MainSetStatus(messagestr);

	r = inst->EngineOpenSession();

	if (r != MAIL_SUCCESS) {
	    handle_mail_error(r);
	    return;
	}

	/* Get the current message # */

	if (msg <= 0 || msg == 0xFFFF) {
	    if (msg == 0)
		inst->MainSetStatus("");
	    if (msg == 0xFFFF)
		inst->MainSetStatus("Message has been deleted!");
	} else {
	    get_message(msg, 1);
	    inst->MainSetStatus("");
	}

	inst->EngineCloseSession();
    }

    Fl::event_clicks(0);
}

void
save_message_callback()
{

    NxMail *inst = NxMail::Inst();

    Fl_Browser *mimelist = inst->ViewerGetMimeWidget();

    int list = mimelist->value();
    int sect = (int) mimelist->data(list);

    save_section_to_file(sect, "blah");

    inst->MainShowWindow();
}

void
view_message_callback()
{

    NxMail *inst = NxMail::Inst();

    Fl_Browser *mimelist = inst->ViewerGetMimeWidget();

    int list = mimelist->value();
    int sect = (int) mimelist->data(list);

    printf("Calling do mime_viewer with %d\n", sect);

    do_mime_viewer(sect);
}

--- NEW FILE: actions.cxx ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "nxmail.h"
#include "callbacks.h"
#include "ui.h"
#include "mailengine.h"
#include "settings.h"
#include "mime.h"

/* LOCAL VALUES AND DEFINES */

#define BUFFER_SIZE 2048	/* 2K of message */
#define MAX_WIDTH 26

static struct
{
    nxmail_header_t *header;
    nxmail_body_t *body;
}
current_message;
static int msgCount = 0;

char *listBuffer = 0;
static char mimeBuffer[100][10];

static void
mail_concat_subject(char *in, char *out, int size)
{
    char *sptr;

    strncpy(out, in, size);
    out[(size / 2)] = 0;

    strcat(out, "...");
    sptr = in + strlen(in) - (size / 2);
    strcat(out, sptr);
}

static void
mail_build_fields(nxmail_header_t * header, char *output)
{
    char fromstr[100];

    sprintf(output, "Subject: %s\n    From: %s\n       To: %s\n\n",
	    header->subject, fromstr, header->to.name);
}

static void
struct_to_addrstr(nxmail_address_t * addr, char *output)
{
    char addrstr[100];

    if (strlen(addr->host))
	sprintf(addrstr, "%s@%s", addr->mailbox, addr->host);
    else
	strcpy(addrstr, addr->mailbox);


    if (strlen(addr->name))
	sprintf(output, "%s <%s>", addr->name, addrstr);
    else
	strcpy(output, addrstr);
}

static void
mail_build_address(nxmail_address_t * addr, char *output)
{
    nxmail_address_t *ptr = addr;

    while (ptr) {
	char addrstr[100];

	if (!strlen(ptr->mailbox))
	    break;

	struct_to_addrstr(ptr, addrstr);

	strcat(output, addrstr);

	if (ptr->next)
	    strcat(output, ",\n");
	ptr = ptr->next;
    }
}

static nxmail_body_t *
get_body_section(int section, nxmail_body_t * head)
{
    nxmail_body_t *ptr = head;

    for (int i = 1; i < section; i++) {
	if (!ptr)
	    return (0);
	ptr = ptr->next;
    }

    return (ptr);
}

static void
mview_insert_field(Fl_Multiline_Output * mview, char *fieldname, char *value)
{
    char addstr[1024];

    bzero(addstr, 1024);

    sprintf(addstr, "%s ", fieldname);

    strncat(addstr, value, 1022 - strlen(addstr));
    strcat(addstr, "\n");

    mview->insert(addstr);
}

void
get_message_list(void)
{

    NxMail *inst = NxMail::Inst();

    char messagestr[50];

    int m = 0;
    int message_count = inst->EngineGetMsgCount();
    Fl_Browser *mlist = inst->MainGetMList();


    //if (listBuffer) free(listBuffer);

    //listBuffer = (char *) calloc(message_count * 50, 1);

    /* Clear the list */
    mlist->clear();

    msgCount = 0;

    //char *listptr = listBuffer;

    for (m = 1; m <= message_count; m++) {
	char listptr[50];

	char outsub[MAX_WIDTH + 5];

	nxmail_header_t *header = inst->EngineFetchHeader(m);

	if (!header)
	    continue;

	if (strlen(header->subject) > MAX_WIDTH)
	    mail_concat_subject(header->subject, outsub, MAX_WIDTH);
	else
	    strcpy(outsub, header->subject);

	msgCount++;

	sprintf(listptr, "%2.2d/%2.2d %2.2d:%2.2d\t%s",
		header->date.month + 1, header->date.day,
		header->date.hour, header->date.min, outsub);

	if (strlen(listptr) > 49)
	    listptr[49] = 0;

	mlist->add((const char *) listptr, (void *) m);
    }

    if (message_count == 0)
	sprintf(messagestr, "No messages on server!");
    else
	sprintf(messagestr, "Got %d messages!", message_count);

    inst->MainSetStatus(messagestr);
}

static void
show_message_header(Fl_Multiline_Output * mview, nxmail_header_t * header)
{
    char fromstr[1024];

    mview_insert_field(mview, "Subject: ", header->subject);

    fromstr[0] = 0;
    mail_build_address(&header->from, fromstr);
    mview_insert_field(mview, "    From: ", fromstr);

    fromstr[0] = 0;
    mail_build_address(&header->to, fromstr);
    mview_insert_field(mview, "      To: ", fromstr);

    fromstr[0] = 0;
    mail_build_address(&header->cc, fromstr);

    if (strlen(fromstr))
	mview_insert_field(mview, "      CC: ", fromstr);
}

static void
fill_mime_browser(Fl_Browser * mbrow, nxmail_body_t * body, int cursection)
{
    nxmail_body_t *bodyptr = body;
    int count = 1;

    mbrow->clear();

    while (bodyptr) {
	if (!strlen(bodyptr->mimeheader.type))
	    sprintf(mimeBuffer[count], "%d: (%d bytes) Message", count,
		    bodyptr->size);
	else
	    sprintf(mimeBuffer[count], "%d: (%d bytes) %s", count,
		    bodyptr->size, bodyptr->mimeheader.type);

	if (strlen(bodyptr->mimeheader.description)) {
	    strcat(mimeBuffer[count], " :");
	    strcat(mimeBuffer[count], bodyptr->mimeheader.description);
	}

	mbrow->add(mimeBuffer[count], (void *) count);
	bodyptr = bodyptr->next;
	count++;
    }

    mbrow->select(cursection);
}

void
delete_message(int msgno)
{
    NxMail *inst = NxMail::Inst();

    Fl_Browser *mlist = inst->MainGetMList();

    int item = mlist->value();

    inst->MainShowWindow();

    if (inst->EngineDeleteMsg(msgno) == NXMAIL_OK) {
	char newline[128];
	sprintf(newline, "@C1 at .%s", mlist->text(item));

	mlist->text(item, newline);
	mlist->data(item, (void *) 0xFFFF);

	// Need to update the list rest of the list and subtract 1 from the message id
	int tcount = mlist->size();
	for (int i = item + 1; i <= tcount; i++) {
	    int mno = (int) mlist->data(i);
	    if (mno <= mlist->size()) {
		mno -= 1;
		mlist->data(i, (void *) mno);
	    }			// end of if
	}			// end of for 

	inst->MainSetStatus("Message deleted.");
	return;
    }

    inst->MainSetStatus("Error!");
}

void
get_message(int msgno, int section)
{

    NxMail *inst = NxMail::Inst();
    MIMESUPPORT supported;

    Fl_Browser *mimelist = inst->ViewerGetMimeWidget();
    Fl_Multiline_Output *mview = inst->ViewerGetMView();

    /* Get the header for the current message */
    nxmail_header_t *remotehdr = inst->EngineFetchHeader(msgno);

    /* Store the pointer locally */
    current_message.header = remotehdr;

    /* Save it locally for replies and such */
    mview->value("");

    if (section == 1)
	show_message_header(mview, remotehdr);

    /* Get the linked list of sections */

    nxmail_body_t *body = inst->EngineFetchMsg(msgno);
    if (!body) {
	current_message.header = 0;
	return;
    }

    current_message.body = body;

    nxmail_body_t *bodypointer = get_body_section(section, body);

    if (!bodypointer) {
	bodypointer = body;
	section = 1;
    }

    if (!strlen(bodypointer->mimeheader.type))
	supported = check_mime_support(remotehdr->mimeheader.type);
    else
	supported = check_mime_support(bodypointer->mimeheader.type);

    switch (supported) {
    case MIME_NOT_SUPPORTED:
    case MIME_SAVE:
	mview->
	    insert
	    ("Sorry!\nThis section of the message is of the\n unsupported type\n");
	mview->insert(bodypointer->mimeheader.type);
	mview->insert("\n");
	mview->position(1);
	break;

    case MIME_TEXT:
	mview->insert("\n");

	mview->insert(bodypointer->text, bodypointer->size);
	mview->position(1);
	break;

    default:
	break;
    }

    fill_mime_browser(mimelist, body, section);

#ifdef NOTUSED

    if (body->next) {

	inst->ViewerShowMimeWidget();
	/* Fill the mime browser */
	fill_mime_browser(mimelist, body, section);
    } else {
	inst->ViewerHideMimeWidget();
    }

#endif

    /* Finally, show the message window */
    inst->ViewerShowWindow();

}

void
reply_to_message(ReplyType type)
{

    NxMail *inst = NxMail::Inst();

    char buffer[2048];

    Fl_Browser *mlist = inst->MainGetMList();

    /* Get the current message */
    int msgno = (int) mlist->data(mlist->value());

    nxmail_header_t *header = inst->EngineFetchHeader(msgno);
    nxmail_body_t *body = inst->EngineFetchMsg(msgno);

    char substr[256];
    char tostr[256];
    char ccstr[256];

    tostr[0] = 0;
    ccstr[0] = 0;

    if (!header && !body)
	return;

    /* Build the address lists if needed */

    if (type == REPLY_SINGLE) {
	mail_build_address(&header->from, tostr);
    }

    if (type == REPLY_ALL) {
	mail_build_address(&header->from, tostr);
	mail_build_address(&header->to, ccstr);
	mail_build_address(&header->cc, ccstr);
    }

    /* Next, build the subject */

    switch (type) {
    case REPLY_ALL:
    case REPLY_SINGLE:
	sprintf(substr, "Re: %s", header->subject);
	break;
    case REPLY_FORWARD:
	sprintf(substr, "Fwd: %s", header->subject);
	break;
    }

    inst->EditorSetFields(tostr, "", substr);

    if (body->size > 2048)
	strncpy(buffer, body->text, 2048);
    else
	strncpy(buffer, body->text, body->size);

    char *textptr = buffer;

    while ((int) (textptr - buffer) < body->size) {
	char linestr[1024];

	bzero(linestr, 1024);
	sscanf(textptr, "%1023[^\n]\n", linestr);

	inst->EditorIndentText(linestr);

	textptr += strlen(linestr);
	textptr++;
    }

    inst->EditorShowWindow();
}

#ifdef NOTUSED

static int
save_section_to_fd(int section, int fd)
{
    nxmail_body_t *sect = get_body_section(section, current_message.body);

    if (sect->mimeheader.encoding == NXMAIL_ENCODING_BASE64) {
	char *outbuffer = (char *) malloc(sect->size);

	if (!outbuffer)
	    return (-1);

	int elen = decode_base64(sect->text, outbuffer, sect->size);

	write(fd, outbuffer, elen);
	free(outbuffer);
    } else {
	write(fd, sect->text, sect->size);
    }

    return 0;
}

#endif

int
save_section_to_file(int section, char *filename)
{
#ifdef NOTUSED
    /* Get the appropriate section for viewing */
    nxmail_body_t *sect = get_body_section(section, current_message.body);

    if (!sect)
	return (-1);

    FILE *fstream = open(filename, F_WRONLY, O_CREAT);
    if (!fstream)
	return (-1);

    if (sect->mimeheader.encoding == NXMAIL_ENCODING_BASE64) {
	char *outbuffer = (char *) malloc(sect->size);

	if (!outbuffer) {
	    fclose(fstream);
	    return;
	}

	int elen = decode_base64(sect->text, outbuffer, sect->size);

	fwrite(outbuffer, elen, 1, fstream);
	free(outbuffer);
    } else {
	fwrite(sect->text, 1, sect->size, fstream);
    }

    fclose(fstream);
#endif

    return 0;
}

void
do_mime_viewer(int section)
{
}

--- NEW FILE: mailengine.cxx ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


/* MAILENGINE.CXX
   
   WRITTEN BY:  Jordan Crouse
                Century Software Embedded Technologies		
*/

#include <stdio.h>

#include "nxmail.h"
#include "mailengine.h"

int
mailEngine::message_count(void)
{
    int mcount;

    if (!_stream)
	return (0);

    if (nxmail_status(_stream, &mcount) != NXMAIL_OK)
	return (0);
    else
	return (mcount);
}

int
mailEngine::active(void)
{
    if (_stream)
	return (1);
    else
	return (0);
}

MAILERROR mailEngine::open_session(char *user, char *password)
{
    int
	ret;
    int
	mailtype =
	0;

    /* If no stream, then start a new one */
    if (!_stream) {
	_stream = nxmail_init_stream();

	if (!_stream) {
	    fprintf(stderr, "MAIL:  Unable to open a new stream\n");
	    return (MAIL_OPEN_ERROR);
	}
    }

    if (_type == MAIL_POP3)
	mailtype = NXMAIL_TYPE_POP3;

    ret = nxmail_open(_stream, _server, _port, mailtype);

    if (ret != NXMAIL_OK) {
	fprintf(stderr, "MAIL:  Unable to open %s:%d\n", _server, _port);
	_stream = 0;

	return (MAIL_OPEN_ERROR);
    }

    if (nxmail_auth(_stream, user, password) != NXMAIL_OK) {
	fprintf(stderr, "MAIL:  Unable to authorize %s!\n", user);
	nxmail_close(_stream);

	_stream = 0;
	return (MAIL_AUTH_ERROR);
    }

    return (MAIL_SUCCESS);
}

void
mailEngine::close_session(void)
{
    if (_stream)
	nxmail_close(_stream);
}

void
mailEngine::reset_engine(char *newserver, int newport, MAILTYPE newtype)
{
    _type = newtype;
    _port = newport;
    strcpy(_server, newserver);

    if (_stream)
	nxmail_close_stream(_stream);
}

nxmail_header_t *
mailEngine::fetch_header(int message)
{
    return (nxmail_fetchheader(_stream, message));
}

nxmail_body_t *
mailEngine::fetch_message(int message)
{
    return (nxmail_fetchbody(_stream, message));
}


int
mailEngine::delete_message(int message)
{
    return (nxmail_delete(_stream, message));
}

MAILERROR
    mailEngine::send_message(char *server, int port,
			     nxmail_header_t * header, char *body, int size)
{
    int ret;

    ret = nxmail_sendmsg(server, port, header, body, size);

    if (ret != NXMAIL_OK)
	return (MAIL_SEND_ERROR);
    else
	return (MAIL_SUCCESS);
}


mailEngine::mailEngine(char *server, int port, MAILTYPE type)
{
    _stream = 0;
    _type = type;
    _port = port;
    strcpy(_server, server);
}

mailEngine::~mailEngine()
{
    if (_stream)
	nxmail_close_stream(_stream);
    _stream = 0;
}

--- NEW FILE: ui.cxx ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
[...1017 lines suppressed...]

#ifdef NOTUSED
    main_category->label(RealCat);
    main_category->hide();
    main_category->show();
    editor_category->label(RealCat);
    editor_category->hide();
    editor_category->show();
    view_category->label(RealCat);
    view_category->hide();
    view_category->show();
#endif

}

void
NxMail::ChangeAcctCB(Fl_Widget * fl, void *o)
{

}

--- NEW FILE: actions.h ---
/*                                                                       
 * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.     
 *                                                                       
 * This file is part of the PIXIL Operating Environment                 
 *                                                                       
 * The use, copying and distribution of this file is governed by one    
 * of two licenses, the PIXIL Commercial License, or the GNU General    
 * Public License, version 2.                                           
 *                                                                       
 * Licensees holding a valid PIXIL Commercial License may use this file 
 * in accordance with the PIXIL Commercial License Agreement provided   
 * with the Software. Others are governed under the terms of the GNU   
 * General Public License version 2.                                    
 *                                                                       
 * This file may be distributed and/or modified under the terms of the  
 * GNU General Public License version 2 as published by the Free        
 * Software Foundation and appearing in the file LICENSE.GPL included   
 * in the packaging of this file.                                      
 *                                                                       
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING  
 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A            
 * PARTICULAR PURPOSE.                                                  
 *                                                                       
 * RESTRICTED RIGHTS LEGEND                                             
 *                                                                     
 * Use, duplication, or disclosure by the government is subject to      
 * restriction as set forth in paragraph (b)(3)(b) of the Rights in     
 * Technical Data and Computer Software clause in DAR 7-104.9(a).       
 *                                                                      
 * See http://www.pixil.org/gpl/ for GPL licensing       
 * information.                                                         
 *                                                                      
 * See http://www.pixil.org/license.html or              
 * email cetsales at centurysoftware.com for information about the PIXIL   
 * Commercial License Agreement, or if any conditions of this licensing 
 * are not clear to you.                                                
 */


#ifndef ACTIONS_H
#define ACTIONS_H

void get_message_list(void);
void delete_message(int);
void get_message(int, int);
void reply_to_message(ReplyType);

int save_section_to_file(int section, char *filename);
void do_mime_viewer(int);

#endif




More information about the dslinux-commit mailing list