bin_PROGRAMS = popproxy
-popproxy_SOURCES = popproxy.c log.c log.h nethook.c nethook.h proto_detect.c proto_detect.h jabber.c jabber.h jabber_server.c iksemel_extra.c iksemel_extra.h null.c null.h ssl.c ssl.h ssl_server.c
+popproxy_SOURCES = popproxy.c log.c log.h nethook.c nethook.h \
+ proto_detect.c proto_detect.h jabber.c jabber.h jabber_server.c \
+ iksemel_extra.c iksemel_extra.h null.c null.h ssl.c ssl.h \
+ ssl_server.c pop.c pop.h
sysconf_DATA = popproxy.conf
--- /dev/null
+/*
+** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
+** Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+**
+** 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 <gnet.h>
+#include <glib.h>
+#include "nethook.h"
+#include "pop.h"
+
+typedef struct
+{
+ net_read orig_read;
+ gpointer orig_data;
+} pop_t;
+
+static void
+pop_read (net_hook_t *hook, gchar *buffer, size_t len)
+{
+ pop_t *pop = hook->data;
+ hook->data = pop->orig_data;
+ pop->orig_read (hook, buffer, len);
+ hook->data = pop;
+}
+
+net_hook_t *
+pop_hook_new (net_hook_t *layer)
+{
+ pop_t *pop;
+ pop = g_slice_new (pop_t);
+ pop->orig_read = layer->read;
+ pop->orig_data = layer->data;
+ layer->read = pop_read;
+ layer->data = pop;
+ return layer;
+}
+
+void
+pop_destroy (net_hook_t *hook)
+{
+ g_slice_free (net_hook_t, hook->data);
+}
--- /dev/null
+/*
+** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
+** Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+**
+** 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.
+**
+*/
+
+#ifndef POPPROXY_POP_H
+#define POPPROXY_POP_H
+
+#include <gnet.h>
+#include "nethook.h"
+
+net_hook_t* pop_hook_new (net_hook_t *);
+void pop_destroy (net_hook_t*);
+
+#endif