claws-mail/src/automaton.c
Christoph Hohmann 6aa3d40bc0 0.8.6claws49
* doc-src/ui_seperation.txt     ** NEW **
        information for ui seperation

* src/Makefile.am
        remove files that were moved to common
        include common directory by default for the header files

* src/inc.c
* src/common/socket.c
* src/automaton.[ch]
        implement automaton using g_io_*-functions instead of
        gdk_input_add to make it ui independent

* src/codeconv.c
* src/compose.c
* src/ldif.c
* src/pgptext.c
* src/procmime.c
* src/rfc2015.c
* src/smtp.c
* src/unmime.c
        remove common/ prefix because directory is now in
        include path

* src/compose.c
* src/folder.c
* src/folderview.c
* src/mainwindow.c
* src/messageview.c
* src/prefs_common.c
* src/procmsg.c
* src/rfc2015.c
        fix warnings

* src/imap.c
* src/inc.c
* src/news.c
* src/pop.c
* src/send.c
* src/smtp.c
* src/ssl_certificate.c
        add log.h header file for logging functions

* src/main.c
* src/common/utils.c
* src/summaryview.c
* src/xml.c
        o move debug_mode to commno/utils.c
        o add functions to set and get debug_mode

* src/defs.h                    ** REMOVE **
* src/intl.h                    ** REMOVE **
* src/socket.[ch]               ** REMOVE **
* src/ssl.[ch]                  ** REMOVE **
* src/utils.[ch]                ** REMOVE **
        replaced by new files in src/common/

* src/common/Makefile.am
        add new files in src/common/

* src/common/defs.h             ** NEW **
* src/common/intl.h             ** NEW **
* src/common/log.[ch]           ** NEW **
* src/common/socket.[ch]        ** NEW **
* src/common/ssl.[ch]           ** NEW **
* src/common/utils.[ch]         ** NEW **
        replacement for files in src/
2002-12-02 17:41:39 +00:00

96 lines
2.3 KiB
C

/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
* Copyright (C) 1999-2002 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtkmain.h>
#include "automaton.h"
Automaton *automaton_create(gint num)
{
Automaton *atm;
g_return_val_if_fail(num > 0, NULL);
atm = g_new0(Automaton, 1);
atm->max = num - 1;
atm->state = g_new0(AtmState, num);
return atm;
}
void automaton_destroy(Automaton *atm)
{
if (!atm) return;
g_free(atm->state);
g_free(atm);
}
gboolean automaton_input_cb(GIOChannel *channel,
GIOCondition condition,
gpointer data)
{
Automaton *atm = (Automaton *)data;
SockInfo *sock;
gint next;
/* We get out sockinfo from the atm context and not from the
* passed file descriptor because we can't map that one back
* to the sockinfo */
sock = atm->help_sock;
g_return_val_if_fail(sock->sock == g_io_channel_unix_get_fd(channel), TRUE);
if (atm->timeout_tag > 0) {
gtk_timeout_remove(atm->timeout_tag);
atm->timeout_tag = 0;
atm->elapsed = 0;
}
gdk_input_remove(atm->tag);
atm->tag = 0;
if (atm->cancelled) {
atm->terminate(sock, data);
return TRUE;
}
if (atm->ui_func)
atm->ui_func(atm->data, atm->num);
next = atm->state[atm->num].handler(sock, atm->data);
if (atm->terminated)
return TRUE;
if (atm->cancelled) {
atm->terminate(sock, data);
return TRUE;
}
if (next >= 0 && next <= atm->max && next != atm->num) {
atm->num = next;
atm->tag = sock_input_add(sock,
atm->state[atm->num].condition,
automaton_input_cb,
data);
} else {
atm->terminate(sock, data);
}
return TRUE;
}