Can check pop3, imap, mailbox, and mdir. Needs testing with imap, mailbox and mdir. Edc needs some work, I'm not entirely happy with it, but the module is in for testing and feedback. SVN revision: 23247master
commit
aefa27599a
20 changed files with 2097 additions and 0 deletions
@ -0,0 +1,24 @@ |
||||
.deps |
||||
.libs |
||||
Makefile |
||||
Makefile.in |
||||
aclocal.m4 |
||||
autom4te.cache |
||||
config.guess |
||||
config.h |
||||
config.h.in |
||||
config.log |
||||
config.status |
||||
config.sub |
||||
configure |
||||
depcomp |
||||
install-sh |
||||
libtool |
||||
missing |
||||
ltmain.sh |
||||
stamp-h1 |
||||
*.lo |
||||
*.la |
||||
*.edj |
||||
*.spec |
||||
*.tar.gz |
@ -0,0 +1,3 @@ |
||||
devilhorns (Christopher Michael) <devilhorns@comcast.net> |
||||
|
||||
Portions of code Copyright (C) 2004 Embrace Project. |
@ -0,0 +1,11 @@ |
||||
COMPILING and INSTALLING: |
||||
|
||||
If you got a official release tar archive do: |
||||
./autogen.sh |
||||
|
||||
Then to compile: |
||||
make |
||||
|
||||
To install: |
||||
make install |
||||
|
@ -0,0 +1,35 @@ |
||||
MAINTAINERCLEANFILES = Makefile.in mkinstalldirs
|
||||
|
||||
EDJE_CC = @edje_cc@
|
||||
EDJE_FLAGS = -v
|
||||
|
||||
# data files for the module
|
||||
filesdir = $(datadir)
|
||||
|
||||
files_DATA = newmail.png module_icon.png module.eap mail.edj
|
||||
|
||||
EXTRA_DIST = $(files_DATA) mount.edc VeraBd.ttf
|
||||
|
||||
# the module .so file
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(includedir) \
|
||||
@e_cflags@
|
||||
|
||||
pkgdir = $(datadir)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h \
|
||||
e_mod_config.c
|
||||
|
||||
module_la_LIBADD = @e_libs@ -lm
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
mail.edj: Makefile mail.edc |
||||
$(EDJE_CC) $(EDJE_FLAGS) \
|
||||
mail.edc \
|
||||
mail.edj
|
||||
|
||||
clean-local: |
||||
rm -rf *.edj *~
|
@ -0,0 +1,4 @@ |
||||
Standard BSD license applies to this code. |
||||
I am not responsible if your computer burns up !! |
||||
If you cannot agree with these restrictions, do not use this module !! |
||||
|
Binary file not shown.
@ -0,0 +1,16 @@ |
||||
#!/bin/sh |
||||
|
||||
rm -rf autom4te.cache |
||||
rm -f aclocal.m4 ltmain.sh |
||||
|
||||
touch README |
||||
|
||||
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1 |
||||
echo "Running autoheader..." ; autoheader || exit 1 |
||||
echo "Running autoconf..." ; autoconf || exit 1 |
||||
echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1 |
||||
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1 |
||||
|
||||
if [ -z "$NOCONFIGURE" ]; then |
||||
./configure "$@" |
||||
fi |
@ -0,0 +1,70 @@ |
||||
/* config.h.in. Generated from configure.in by autoheader. */ |
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */ |
||||
#undef HAVE_DLFCN_H |
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */ |
||||
#undef HAVE_INTTYPES_H |
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */ |
||||
#undef HAVE_MEMORY_H |
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */ |
||||
#undef HAVE_STDINT_H |
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */ |
||||
#undef HAVE_STDLIB_H |
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */ |
||||
#undef HAVE_STRINGS_H |
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */ |
||||
#undef HAVE_STRING_H |
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */ |
||||
#undef HAVE_SYS_STAT_H |
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */ |
||||
#undef HAVE_SYS_TYPES_H |
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */ |
||||
#undef HAVE_UNISTD_H |
||||
|
||||
/* "Module architecture" */ |
||||
#undef MODULE_ARCH |
||||
|
||||
/* Name of package */ |
||||
#undef PACKAGE |
||||
|
||||
/* "Package installed binaries destination" */ |
||||
#undef PACKAGE_BIN_DIR |
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */ |
||||
#undef PACKAGE_BUGREPORT |
||||
|
||||
/* "Package installed data destination" */ |
||||
#undef PACKAGE_DATA_DIR |
||||
|
||||
/* "Package installed libraries destination" */ |
||||
#undef PACKAGE_LIB_DIR |
||||
|
||||
/* Define to the full name of this package. */ |
||||
#undef PACKAGE_NAME |
||||
|
||||
/* Define to the full name and version of this package. */ |
||||
#undef PACKAGE_STRING |
||||
|
||||
/* Define to the one symbol short name of this package. */ |
||||
#undef PACKAGE_TARNAME |
||||
|
||||
/* Define to the version of this package. */ |
||||
#undef PACKAGE_VERSION |
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */ |
||||
#undef STDC_HEADERS |
||||
|
||||
/* Version number of package */ |
||||
#undef VERSION |
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */ |
||||
#undef const |
@ -0,0 +1,138 @@ |
||||
dnl Process this file with autoconf to produce a configure script. |
||||
|
||||
# get rid of that stupid cache mechanism |
||||
rm -f config.cache |
||||
|
||||
AC_INIT(configure.in) |
||||
AC_CANONICAL_BUILD |
||||
AC_CANONICAL_HOST |
||||
|
||||
AM_INIT_AUTOMAKE(mail, 0.0.1) |
||||
AM_CONFIG_HEADER(config.h) |
||||
|
||||
AC_ISC_POSIX |
||||
AC_PROG_CC |
||||
AM_PROG_CC_STDC |
||||
AC_HEADER_STDC |
||||
AC_C_CONST |
||||
AM_ENABLE_SHARED |
||||
AM_PROG_LIBTOOL |
||||
|
||||
MODULE_ARCH="$host_os-$host_cpu" |
||||
AC_SUBST(MODULE_ARCH) |
||||
AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture") |
||||
|
||||
if test "x${bindir}" = 'x${exec_prefix}/bin'; then |
||||
if test "x${exec_prefix}" = "xNONE"; then |
||||
if test "x${prefix}" = "xNONE"; then |
||||
bindir="${ac_default_prefix}/bin"; |
||||
else |
||||
bindir="${prefix}/bin"; |
||||
fi |
||||
else |
||||
if test "x${prefix}" = "xNONE"; then |
||||
bindir="${ac_default_prefix}/bin"; |
||||
else |
||||
bindir="${prefix}/bin"; |
||||
fi |
||||
fi |
||||
fi |
||||
|
||||
if test "x${libdir}" = 'x${exec_prefix}/lib'; then |
||||
if test "x${exec_prefix}" = "xNONE"; then |
||||
if test "x${prefix}" = "xNONE"; then |
||||
libdir="${ac_default_prefix}/lib"; |
||||
else |
||||
libdir="${prefix}/lib"; |
||||
fi |
||||
else |
||||
if test "x${prefix}" = "xNONE"; then |
||||
libdir="${ac_default_prefix}/lib"; |
||||
else |
||||
libdir="${prefix}/lib"; |
||||
fi |
||||
fi |
||||
fi |
||||
|
||||
dnl Set PACKAGE_BIN_DIR in config.h. |
||||
if test "x${bindir}" = 'xNONE'; then |
||||
if test "x${prefix}" = "xNONE"; then |
||||
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${ac_default_prefix}/bin", "Package installed binaries destination") |
||||
else |
||||
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${prefix}/bin", "Package installed binaries destination") |
||||
fi |
||||
else |
||||
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${bindir}", "Package installed binaries destination") |
||||
fi |
||||
|
||||
dnl Set PACKAGE_LIB_DIR in config.h. |
||||
if test "x${libdir}" = 'xNONE'; then |
||||
if test "x${prefix}" = "xNONE"; then |
||||
AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${ac_default_prefix}/lib", "Package installed libraries destination") |
||||
else |
||||
AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${prefix}/lib", "Package installed libraries destination") |
||||
fi |
||||
else |
||||
AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${libdir}", "Package installed libraries destination") |
||||
fi |
||||
|
||||
dnl Set PACKAGE_DATA_DIR in config.h. |
||||
if test "x${prefix}" = "xNONE"; then |
||||
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${HOME}/.e/e/modules/${PACKAGE}", "Package installed data destination") |
||||
datadir="${HOME}/.e/e/modules/${PACKAGE}" |
||||
else |
||||
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/lib/enlightenment/modules/${PACKAGE}", "Package installed data destination") |
||||
datadir="${prefix}/lib/enlightenment/modules/${PACKAGE}" |
||||
fi |
||||
|
||||
#AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl) |
||||
#AC_SUBST(dlopen_libs) |
||||
|
||||
AC_ARG_WITH(edje-config, |
||||
[ --with-edje-config=EDJE_CONFIG use edje-config specified ], |
||||
[ |
||||
EDJE_CONFIG=$withval; |
||||
echo "using "$EDJE_CONFIG" for edje-config"; |
||||
/ |
||||
],[ |
||||
PROG="edje-config"; |
||||
AC_PATH_PROG(EDJE_CONFIG, $PROG, "", $PATH) |
||||
]) |
||||
edje_cflags=`$EDJE_CONFIG --cflags` |
||||
edje_libs=`$EDJE_CONFIG --libs` |
||||
AC_SUBST(edje_cflags) |
||||
AC_SUBST(edje_libs) |
||||
|
||||
edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc" |
||||
AC_ARG_WITH(edje-cc, |
||||
[ --with-edje-cc=PATH specify a specific path to edje_cc], |
||||
[ |
||||
v=$withval; |
||||
edje_cc=$v |
||||
echo " Enlightenment edje_cc explicitly set to "$edje_cc; |
||||
],[ |
||||
edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc" |
||||
]) |
||||
AC_SUBST(edje_cc) |
||||
|
||||
AC_ARG_WITH(enlightenment-config, |
||||
[ --with-enlightenment-config=E_CONFIG use enlightenment-config specified ], |
||||
[ |
||||
E_CONFIG=$withval; |
||||
echo "using "$E_CONFIG" for enlightenment-config"; |
||||
],[ |
||||
PROG="enlightenment-config"; |
||||
AC_PATH_PROG(E_CONFIG, $PROG, "", $PATH) |
||||
]) |
||||
e_cflags=`$E_CONFIG --cflags` |
||||
e_libs=`$E_CONFIG --libs` |
||||
e_modules=`$E_CONFIG --module-dir` |
||||
AC_SUBST(e_cflags) |
||||
AC_SUBST(e_libs) |
||||
AC_SUBST(e_modules) |
||||
|
||||
AC_OUTPUT([ |
||||
Makefile |
||||
],[ |
||||
]) |
||||
|
@ -0,0 +1,293 @@ |
||||
#include <e.h> |
||||
#include "e_mod_main.h" |
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{ |
||||
int show_label; |
||||
int use_exec; |
||||
int type; |
||||
double check_time; |
||||
|
||||
char *exec;
|
||||
char *host; |
||||
char *user; |
||||
char *pass; |
||||
char *path; |
||||
char *path_current; |
||||
|
||||
Evas_Object *new_path_label; |
||||
Evas_Object *new_path_entry; |
||||
Evas_Object *cur_path_label; |
||||
Evas_Object *cur_path_entry; |
||||
|
||||
Evas_Object *exec_label; |
||||
Evas_Object *exec_entry; |
||||
}; |
||||
|
||||
static void *_create_data(E_Config_Dialog *cfd); |
||||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); |
||||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); |
||||
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); |
||||
|
||||
static void _use_exec_cb_change(void *data, Evas_Object *obj); |
||||
static void _mail_type_cb_change(void *data, Evas_Object *obj); |
||||
|
||||
void |
||||
_config_mail_module(Config_Item *ci)
|
||||
{ |
||||
E_Config_Dialog *cfd; |
||||
E_Config_Dialog_View *v; |
||||
E_Container *con; |
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1); |
||||
if (!v) return; |
||||
|
||||
v->create_cfdata = _create_data; |
||||
v->free_cfdata = _free_data; |
||||
v->basic.apply_cfdata = _basic_apply_data; |
||||
v->basic.create_widgets = _basic_create_widgets; |
||||
|
||||
con = e_container_current_get(e_manager_current_get()); |
||||
cfd = e_config_dialog_new(con, _("Mail Configuration"), NULL, 0, v, ci); |
||||
mail_config->config_dialog = cfd; |
||||
} |
||||
|
||||
static void |
||||
_fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
|
||||
{ |
||||
cfdata->host = NULL; |
||||
cfdata->user = NULL; |
||||
cfdata->pass = NULL; |
||||
cfdata->exec = NULL; |
||||
cfdata->path = NULL; |
||||
cfdata->path_current = NULL; |
||||
|
||||
if (ci->host) |
||||
cfdata->host = strdup(ci->host); |
||||
if (ci->user) |
||||
cfdata->user = strdup(ci->user); |
||||
if (ci->pass) |
||||
cfdata->pass = strdup(ci->pass); |
||||
if (ci->exec) |
||||
cfdata->exec = strdup(ci->exec); |
||||
if (ci->path) |
||||
cfdata->path = strdup(ci->path); |
||||
if (ci->path_current) |
||||
cfdata->path_current = strdup(ci->path_current); |
||||
|
||||
cfdata->show_label = ci->show_label; |
||||
cfdata->type = ci->type; |
||||
cfdata->use_exec = ci->use_exec; |
||||
cfdata->check_time = ci->check_time; |
||||
} |
||||
|
||||
static void * |
||||
_create_data(E_Config_Dialog *cfd)
|
||||
{ |
||||
E_Config_Dialog_Data *cfdata; |
||||
Config_Item *ci; |
||||
|
||||
ci = cfd->data; |
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1); |
||||
_fill_data(ci, cfdata); |
||||
return cfdata; |
||||
} |
||||
|
||||
static void |
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{ |
||||
if (!mail_config) return; |
||||
mail_config->config_dialog = NULL; |
||||
free(cfdata->host); |
||||
free(cfdata->user); |
||||
free(cfdata->pass); |
||||
free(cfdata->exec); |
||||
free(cfdata->path); |
||||
free(cfdata->path_current); |
||||
free(cfdata); |
||||
} |
||||
|
||||
static Evas_Object * |
||||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{ |
||||
Evas_Object *o, *of, *ob, *ot; |
||||
E_Radio_Group *rg; |
||||
|
||||
o = e_widget_list_add(evas, 0, 0); |
||||
of = e_widget_framelist_add(evas, _("General Settings"), 0); |
||||
ob = e_widget_check_add(evas, _("Always Show Labels"), &(cfdata->show_label)); |
||||
e_widget_framelist_object_append(of, ob); |
||||
ob = e_widget_label_add(evas, _("Check Interval")); |
||||
e_widget_framelist_object_append(of, ob); |
||||
ob = e_widget_slider_add(evas, 1, 0, _("%2.0f minutes"), 1.0, 60.0, 1.0, 0, &(cfdata->check_time), NULL, 100); |
||||
e_widget_framelist_object_append(of, ob); |
||||
ob = e_widget_check_add(evas, _("Start Program When New Mail Arrives"), &(cfdata->use_exec)); |
||||
e_widget_framelist_object_append(of, ob); |
||||
e_widget_on_change_hook_set(ob, _use_exec_cb_change, cfdata); |
||||
|
||||
ot = e_widget_table_add(evas, 1); |
||||
cfdata->exec_label = e_widget_label_add(evas, _("Mail Program:")); |
||||
e_widget_table_object_append(ot, cfdata->exec_label, 0, 0, 1, 1, 0, 0, 1, 0); |
||||
cfdata->exec_entry = e_widget_entry_add(evas, &cfdata->exec); |
||||
e_widget_table_object_append(ot, cfdata->exec_entry, 1, 0, 1, 1, 0, 0, 1, 0); |
||||
e_widget_framelist_object_append(of, ot); |
||||
e_widget_list_object_append(o, of, 1, 1, 0.5); |
||||
|
||||
e_widget_disabled_set(cfdata->exec_label, !cfdata->use_exec); |
||||
e_widget_disabled_set(cfdata->exec_entry, !cfdata->use_exec);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Mailbox Type"), 0); |
||||
rg = e_widget_radio_group_new(&(cfdata->type)); |
||||
ob = e_widget_radio_add(evas, _("Pop3"), 0, rg); |
||||
e_widget_on_change_hook_set(ob, _mail_type_cb_change, cfdata); |
||||
e_widget_framelist_object_append(of, ob); |
||||
ob = e_widget_radio_add(evas, _("Imap"), 1, rg); |
||||
e_widget_on_change_hook_set(ob, _mail_type_cb_change, cfdata); |
||||
e_widget_framelist_object_append(of, ob); |
||||
ob = e_widget_radio_add(evas, _("Maildir"), 2, rg); |
||||
e_widget_on_change_hook_set(ob, _mail_type_cb_change, cfdata); |
||||
e_widget_framelist_object_append(of, ob); |
||||
ob = e_widget_radio_add(evas, _("Mbox"), 3, rg); |
||||
e_widget_on_change_hook_set(ob, _mail_type_cb_change, cfdata); |
||||
e_widget_framelist_object_append(of, ob); |
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Mailbox Settings"), 1); |
||||
ob = e_widget_label_add(evas, _("Mail Host:")); |
||||
e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 0, 0, 1, 0); |
||||
ob = e_widget_entry_add(evas, &cfdata->host); |
||||
e_widget_frametable_object_append(of, ob, 1, 0, 1, 1, 0, 0, 1, 0); |
||||
|
||||
ob = e_widget_label_add(evas, _("Username:")); |
||||
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 0, 0, 1, 0); |
||||
ob = e_widget_entry_add(evas, &cfdata->user); |
||||
e_widget_frametable_object_append(of, ob, 1, 1, 1, 1, 0, 0, 1, 0); |
||||
|
||||
ob = e_widget_label_add(evas, _("Password:")); |
||||
e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 0, 0, 1, 0); |
||||
ob = e_widget_entry_add(evas, &cfdata->pass); |
||||
e_widget_entry_password_set(ob, 1); |
||||
e_widget_frametable_object_append(of, ob, 1, 2, 1, 1, 0, 0, 1, 0); |
||||
|
||||
cfdata->new_path_label = e_widget_label_add(evas, _("New Mail Path:")); |
||||
e_widget_frametable_object_append(of, cfdata->new_path_label, 0, 3, 1, 1, 0, 0, 1, 0); |
||||
cfdata->new_path_entry = e_widget_entry_add(evas, &cfdata->path); |
||||
e_widget_frametable_object_append(of, cfdata->new_path_entry, 1, 3, 1, 1, 0, 0, 1, 0); |
||||
if (cfdata->type == 0)
|
||||
{ |
||||
e_widget_disabled_set(cfdata->new_path_label, 1); |
||||
e_widget_disabled_set(cfdata->new_path_entry, 1); |
||||
} |
||||
|
||||
cfdata->cur_path_label = e_widget_label_add(evas, _("Current Mail Path:")); |
||||
e_widget_frametable_object_append(of, cfdata->cur_path_label, 0, 4, 1, 1, 0, 0, 1, 0); |
||||
cfdata->cur_path_entry = e_widget_entry_add(evas, &cfdata->path_current); |
||||
e_widget_frametable_object_append(of, cfdata->cur_path_entry, 1, 4, 1, 1, 0, 0, 1, 0); |
||||
if ((cfdata->type == 0) || (cfdata->type == 2))
|
||||
{ |
||||
e_widget_disabled_set(cfdata->cur_path_label, 1); |
||||
e_widget_disabled_set(cfdata->cur_path_entry, 1); |
||||
} |
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5); |
||||
return o; |
||||
} |
||||
|
||||
static int |
||||
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{ |
||||
Config_Item *ci; |
||||
|
||||
ci = cfd->data; |
||||
|
||||
if (ci->host) evas_stringshare_del(ci->host); |
||||
if (cfdata->host != NULL) |
||||
ci->host = evas_stringshare_add(cfdata->host); |
||||
else |
||||
ci->host = evas_stringshare_add(""); |
||||
|
||||
if (ci->user) evas_stringshare_del(ci->user); |
||||
if (cfdata->user != NULL) |
||||
ci->user = evas_stringshare_add(cfdata->user); |
||||
else |
||||
ci->user = evas_stringshare_add(""); |
||||
|
||||
if (ci->pass) evas_stringshare_del(ci->pass); |
||||
if (cfdata->pass != NULL) |
||||
ci->pass = evas_stringshare_add(cfdata->pass); |
||||
else |
||||
ci->pass = evas_stringshare_add(""); |
||||
|
||||
if (ci->path) evas_stringshare_del(ci->path); |
||||
if (cfdata->path != NULL) |
||||
ci->path = evas_stringshare_add(cfdata->path); |
||||
else |
||||
ci->path = evas_stringshare_add(""); |
||||
|
||||
if (ci->path_current) evas_stringshare_del(ci->path_current); |
||||
if (cfdata->path_current != NULL) |
||||
ci->path_current = evas_stringshare_add(cfdata->path_current); |
||||
else |
||||
ci->path_current = evas_stringshare_add(""); |
||||
|
||||
if (ci->exec) evas_stringshare_del(ci->exec);
|
||||
if (cfdata->exec != NULL) |
||||
ci->exec = evas_stringshare_add(cfdata->exec); |
||||
else |
||||
ci->exec = evas_stringshare_add(""); |
||||
|
||||
ci->show_label = cfdata->show_label; |
||||
ci->type = cfdata->type; |
||||
ci->use_exec = cfdata->use_exec; |
||||
ci->check_time = cfdata->check_time; |
||||
|
||||
e_config_save_queue(); |
||||
_mail_config_updated(ci->id); |
||||
return 1; |
||||
} |
||||
|
||||
static void
|
||||
_use_exec_cb_change(void *data, Evas_Object *obj)
|
||||
{ |
||||
E_Config_Dialog_Data *cfdata; |
||||
|
||||
cfdata = data; |
||||
e_widget_disabled_set(cfdata->exec_label, !cfdata->use_exec); |
||||
e_widget_disabled_set(cfdata->exec_entry, !cfdata->use_exec); |
||||
if (!cfdata->use_exec) |
||||
e_widget_entry_text_set(cfdata->exec_entry, ""); |
||||
} |
||||
|
||||
static void
|
||||
_mail_type_cb_change(void *data, Evas_Object *obj)
|
||||
{ |
||||
E_Config_Dialog_Data *cfdata; |
||||
|
||||
cfdata = data; |
||||
if (cfdata->type == 0)
|
||||
{ |
||||
e_widget_disabled_set(cfdata->new_path_label, 1); |
||||
e_widget_disabled_set(cfdata->new_path_entry, 1); |
||||
e_widget_disabled_set(cfdata->cur_path_label, 1); |
||||
e_widget_disabled_set(cfdata->cur_path_entry, 1); |
||||
e_widget_entry_text_set(cfdata->new_path_entry, ""); |
||||
e_widget_entry_text_set(cfdata->cur_path_entry, ""); |
||||
} |
||||
else if ((cfdata->type == 1) || (cfdata->type == 3)) |
||||
{ |
||||
e_widget_disabled_set(cfdata->new_path_label, 0); |
||||
e_widget_disabled_set(cfdata->new_path_entry, 0); |
||||
e_widget_disabled_set(cfdata->cur_path_label, 1); |
||||
e_widget_disabled_set(cfdata->cur_path_entry, 1); |
||||
e_widget_entry_text_set(cfdata->cur_path_entry, "");
|
||||
} |
||||
else if (cfdata->type == 2)
|
||||
{ |
||||
e_widget_disabled_set(cfdata->new_path_label, 0); |
||||
e_widget_disabled_set(cfdata->new_path_entry, 0); |
||||
e_widget_disabled_set(cfdata->cur_path_label, 0); |
||||
e_widget_disabled_set(cfdata->cur_path_entry, 0);
|
||||
} |
||||
} |
||||
|
@ -0,0 +1,856 @@ |
||||
/*
|
||||
* Copyright (C) 2006 Christopher Michael |
||||
* |
||||
* Portions of this code Copyright (C) 2004 Embrace project. |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of version 2 of the GNU General Public License as |
||||
* published by the Free Software Foundation. |
||||
* |
||||
* 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 <sys/types.h> |
||||
#include <dirent.h> |
||||
#include <e.h> |
||||
#include <Ecore.h> |
||||
#include <Ecore_File.h> |
||||
#include "e_mod_main.h" |
||||
|
||||
typedef enum
|
||||
{ |
||||
MAIL_TYPE_POP, |
||||
MAIL_TYPE_IMAP, |
||||
MAIL_TYPE_MDIR, |
||||
MAIL_TYPE_MBOX |
||||
} MailType; |
||||
|
||||
typedef enum
|
||||
{ |
||||
STATE_DISCONNECTED, |
||||
STATE_CONNECTED, |
||||
STATE_SERVER_READY, |
||||
STATE_LOGGED_IN,
|
||||
STATE_USER_OK, |
||||
STATE_PASS_OK, |
||||
STATE_STATUS_OK |
||||
} State; |
||||
|
||||
typedef struct _Instance Instance; |
||||
typedef struct _Mail Mail; |
||||
|
||||
struct _Instance
|
||||
{ |
||||
E_Gadcon_Client *gcc; |
||||
Evas_Object *mail_obj; |
||||
Mail *mail; |
||||
Ecore_Timer *check_timer; |
||||
Ecore_Con_Server *server; |
||||
Ecore_Event_Handler *add_handler; |
||||
Ecore_Event_Handler *del_handler; |
||||
Ecore_Event_Handler *data_handler; |
||||
Ecore_File_Monitor *monitor; |
||||
Ecore_Exe *exe; |
||||
Ecore_Event_Handler *exit_handler; |
||||
int state; |
||||
int cmd; |
||||
}; |
||||
|
||||
struct _Mail |
||||
{ |
||||
Instance *inst; |
||||
Evas_Object *mail_obj; |
||||
}; |
||||
|
||||
/* Func Protos for Gadcon */ |
||||
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style); |
||||
static void _gc_shutdown(E_Gadcon_Client *gcc); |
||||
static void _gc_orient(E_Gadcon_Client *gcc); |
||||
static char *_gc_label(void); |
||||
static Evas_Object *_gc_icon(Evas *evas); |
||||
|
||||
/* Func Protos for Module */ |
||||
static void _mail_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); |
||||
static void _mail_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info); |
||||
static void _mail_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info); |
||||
static void _mail_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi); |
||||
static void _mail_menu_cb_post(void *data, E_Menu *m); |
||||
static Config_Item *_mail_config_item_get(const char *id); |
||||
static Mail *_mail_new(Evas *evas); |
||||
static void _mail_free(Mail *mail); |
||||
static int _mail_cb_check(void *data); |
||||
static int _mail_server_add(void *data, int type, void *event); |
||||
static int _mail_server_del(void *data, int type, void *event); |
||||
static int _mail_server_data(void *data, int type, void *event); |
||||
static int _mail_parse_pop(void *data, void *data2); |
||||
static int _mail_parse_imap(void *data, void *data2); |
||||
static void _mail_mbox_check(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path); |
||||
static void _mail_mdir_check(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path); |
||||
static int _mail_mdir_get_files(const char *path); |
||||
static void _mail_set_text(void *data, int n, int t); |
||||
static int _mail_cb_exe_exit(void *data, int type, void *event); |
||||
|
||||
static E_Config_DD *conf_edd = NULL; |
||||
static E_Config_DD *conf_item_edd = NULL; |
||||
|
||||
Config *mail_config = NULL; |
||||
|
||||
static const E_Gadcon_Client_Class _gc_class =
|
||||
{ |
||||
GADCON_CLIENT_CLASS_VERSION, |
||||
"mail", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon} |
||||
}; |
||||
|
||||
static E_Gadcon_Client * |
||||
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||
{ |
||||
Evas_Object *o; |
||||
E_Gadcon_Client *gcc; |
||||
Instance *inst; |
||||
Mail *mail; |
||||
Config_Item *ci; |
||||
char buf[4096]; |
||||
|
||||
inst = E_NEW(Instance, 1); |
||||
ci = _mail_config_item_get(id); |
||||
if (!ci->id) ci->id = evas_stringshare_add(id); |
||||
|
||||
mail = _mail_new(gc->evas); |
||||
mail->inst = inst; |
||||
inst->mail = mail; |
||||
|
||||
o = mail->mail_obj; |
||||
gcc = e_gadcon_client_new(gc, name, id, style, o); |
||||
gcc->data = inst; |
||||
inst->gcc = gcc; |
||||
inst->mail_obj = o; |
||||
|
||||
if (ci->type == MAIL_TYPE_MDIR)
|
||||
inst->monitor = ecore_file_monitor_add(ci->path, _mail_mdir_check, inst); |
||||
else if (ci->type == MAIL_TYPE_MBOX)
|
||||
inst->monitor = ecore_file_monitor_add(ci->path, _mail_mbox_check, inst); |
||||
else
|
||||
{ |
||||
if (!inst->add_handler) |
||||
inst->add_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _mail_server_add, inst); |
||||
if (!inst->del_handler) |
||||
inst->del_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _mail_server_del, inst); |
||||
if (!inst->data_handler) |
||||
inst->data_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _mail_server_data, inst); |
||||
|
||||
_mail_cb_check(inst); |
||||
if (!inst->check_timer) |
||||
inst->check_timer = ecore_timer_add((ci->check_time * 60.0), _mail_cb_check, inst); |
||||
} |
||||
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mail_cb_mouse_down, inst); |
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _mail_cb_mouse_in, inst); |
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _mail_cb_mouse_out, inst); |
||||
|
||||
if (ci->show_label) |
||||
edje_object_signal_emit(inst->mail_obj, "label_active", ""); |
||||
else |
||||
edje_object_signal_emit(inst->mail_obj, "label_passive", ""); |
||||
|
||||
edje_object_part_text_set(inst->mail_obj, "name", ci->user); |
||||
|
||||
mail_config->instances = evas_list_append(mail_config->instances, inst); |
||||
return gcc; |
||||
} |
||||
|
||||
static void |
||||
_gc_shutdown(E_Gadcon_Client *gcc)
|
||||
{ |
||||
Instance *inst; |
||||
|
||||
inst = gcc->data; |
||||
if (inst->monitor) ecore_file_monitor_del(inst->monitor); |
||||
if (inst->check_timer) ecore_timer_del(inst->check_timer); |
||||
if (inst->add_handler) ecore_event_handler_del(inst->add_handler); |
||||
if (inst->data_handler) ecore_event_handler_del(inst->data_handler); |
||||
if (inst->del_handler) ecore_event_handler_del(inst->del_handler); |
||||
if (inst->server) ecore_con_server_del(inst->server); |
||||
inst->server = NULL; |
||||
|
||||
evas_object_event_callback_del(inst->mail->mail_obj, EVAS_CALLBACK_MOUSE_DOWN, _mail_cb_mouse_down); |
||||
evas_object_event_callback_del(inst->mail->mail_obj, EVAS_CALLBACK_MOUSE_IN, _mail_cb_mouse_in); |
||||
evas_object_event_callback_del(inst->mail->mail_obj, EVAS_CALLBACK_MOUSE_OUT, _mail_cb_mouse_out);
|
||||
|
||||
mail_config->instances = evas_list_remove(mail_config->instances, inst); |
||||
_mail_free(inst->mail); |
||||
free(inst); |
||||
} |
||||
|
||||
static void |
||||
_gc_orient(E_Gadcon_Client *gcc)
|
||||
{ |
||||
e_gadcon_client_aspect_set(gcc, 16, 16); |
||||
e_gadcon_client_min_size_set(gcc, 16, 16); |
||||
} |
||||
|
||||
static char * |
||||
_gc_label(void)
|
||||
{ |
||||
return D_("Mail"); |
||||
} |
||||
|
||||
static Evas_Object * |
||||
_gc_icon(Evas *evas)
|
||||
{ |
||||
Evas_Object *o; |
||||
char buf[4096]; |
||||
|
||||
o = edje_object_add(evas); |
||||
snprintf(buf, sizeof(buf), "%s/module.eap", e_module_dir_get(mail_config->module)); |
||||
edje_object_file_set(o, buf, "icon"); |
||||
return o; |
||||
} |
||||
|
||||
static void |
||||
_mail_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{ |
||||
Instance *inst; |
||||
Evas_Event_Mouse_Down *ev; |
||||
|
||||
inst = data; |
||||
ev = event_info; |
||||
if ((ev->button == 3) && (!mail_config->menu))
|
||||
{ |
||||
E_Menu *mn; |
||||
E_Menu_Item *mi; |
||||
int x, y, w, h; |
||||
|
||||
mn = e_menu_new(); |
||||
e_menu_post_deactivate_callback_set(mn, _mail_menu_cb_post, inst); |
||||
mail_config->menu = mn; |
||||
|
||||
mi = e_menu_item_new(mn); |
||||
e_menu_item_label_set(mi, _("Configuration")); |
||||
e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration"); |
||||
e_menu_item_callback_set(mi, _mail_menu_cb_configure, inst); |
||||
|
||||
mi = e_menu_item_new(mn); |
||||
e_menu_item_separator_set(mi, 1); |
||||
|
||||
e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0); |
||||
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, &w, &h); |
||||
e_menu_activate_mouse(mn, |
||||
e_util_zone_current_get(e_manager_current_get()), |
||||
x + ev->output.x, y + ev->output.y, 1, 1, E_MENU_POP_DIRECTION_DOWN, |
||||
ev->timestamp); |
||||
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button, EVAS_BUTTON_NONE, ev->timestamp, NULL); |
||||
} |
||||
else if ((ev->button == 1) && (inst)) |
||||
_mail_cb_check(inst); |
||||
} |
||||
|
||||
static void
|
||||
_mail_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{ |
||||
Instance *inst; |
||||
|
||||
inst = data; |
||||
edje_object_signal_emit(inst->mail_obj, "label_active", ""); |
||||
} |
||||
|
||||
static void
|
||||
_mail_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{ |
||||
Instance *inst; |
||||
Config_Item *ci; |
||||
|
||||
inst = data; |
||||
ci = _mail_config_item_get(inst->gcc->id); |
||||
if (!ci->show_label) |
||||
edje_object_signal_emit(inst->mail_obj, "label_passive", ""); |
||||
} |
||||
|
||||
static void |
||||
_mail_menu_cb_post(void *data, E_Menu *m)
|
||||
{ |
||||
if (!mail_config->menu) return; |
||||
e_object_del(E_OBJECT(mail_config->menu)); |
||||
mail_config->menu = NULL; |
||||
} |
||||
|
||||
static void |
||||
_mail_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
{ |
||||
Instance *inst; |
||||
Config_Item *ci; |
||||
|
||||
inst = data; |
||||
ci = _mail_config_item_get(inst->gcc->id); |
||||
_config_mail_module(ci); |
||||
} |
||||
|
||||
static Config_Item * |
||||
_mail_config_item_get(const char *id)
|
||||
{ |
||||
Evas_List *l; |
||||
Config_Item *ci; |
||||
|
||||
for (l = mail_config->items; l; l = l->next)
|
||||
{ |
||||
ci = l->data; |
||||
if (!ci->id) continue; |
||||
if (!strcmp(ci->id, id)) return ci; |
||||
} |
||||
|
||||
ci = E_NEW(Config_Item, 1); |
||||
ci->id = evas_stringshare_add(id); |
||||
ci->host = evas_stringshare_add(""); |
||||
ci->port = 110; |
||||
ci->user = evas_stringshare_add(""); |
||||
ci->pass = evas_stringshare_add(""); |
||||
ci->exec = evas_stringshare_add(""); |
||||
ci->path = evas_stringshare_add(""); |
||||
ci->path_current = evas_stringshare_add(""); |
||||
ci->show_label = 1; |
||||
ci->type = MAIL_TYPE_POP; |
||||
ci->use_exec = 0; |
||||
ci->check_time = 15.0; |
||||
|
||||
mail_config->items = evas_list_append(mail_config->items, ci); |
||||
return ci; |
||||
} |
||||
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{ |
||||
E_MODULE_API_VERSION, |
||||
"Mail" |
||||
}; |
||||
|
||||
EAPI void * |
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
conf_item_edd = E_CONFIG_DD_NEW("Mail_Config_Item", Config_Item); |
||||
#undef T |
||||
#undef D |
||||
#define T Config_Item |
||||
#define D conf_item_edd |
||||
E_CONFIG_VAL(D, T, id, STR); |
||||
E_CONFIG_VAL(D, T, host, STR); |
||||
E_CONFIG_VAL(D, T, port, INT); |
||||
E_CONFIG_VAL(D, T, user, STR); |
||||
E_CONFIG_VAL(D, T, pass, STR); |
||||
E_CONFIG_VAL(D, T, exec, STR); |
||||
E_CONFIG_VAL(D, T, path, STR); |
||||
E_CONFIG_VAL(D, T, path_current, STR); |
||||
E_CONFIG_VAL(D, T, show_label, UCHAR); |
||||
E_CONFIG_VAL(D, T, use_exec, UCHAR); |
||||
E_CONFIG_VAL(D, T, type, INT); |
||||
E_CONFIG_VAL(D, T, check_time, DOUBLE); |
||||
|
||||
conf_edd = E_CONFIG_DD_NEW("Mail_Config", Config); |
||||
#undef T |
||||
#undef D |
||||
#define T Config |
||||
#define D conf_edd |
||||
E_CONFIG_LIST(D, T, items, conf_item_edd); |
||||
|
||||
mail_config = e_config_domain_load("module.mail", conf_edd); |
||||
if (!mail_config)
|
||||
{ |
||||
Config_Item *ci; |
||||
|
||||
mail_config = E_NEW(Config, 1); |
||||
ci = E_NEW(Config_Item, 1); |
||||
|
||||
ci->id = evas_stringshare_add("0"); |
||||
ci->host = evas_stringshare_add(""); |
||||
ci->port = 110; |
||||
ci->user = evas_stringshare_add(""); |
||||
ci->pass = evas_stringshare_add(""); |
||||
ci->exec = evas_stringshare_add(""); |
||||
ci->path = evas_stringshare_add(""); |
||||
ci->path_current = evas_stringshare_add("");
|
||||
ci->show_label = 1; |
||||
ci->type = MAIL_TYPE_POP;
|
||||
ci->use_exec = 0; |
||||
ci->check_time = 15.0; |
||||
mail_config->items = evas_list_append(mail_config->items, ci); |
||||
} |
||||
mail_config->module = m; |
||||
e_gadcon_provider_register(&_gc_class); |
||||
return 1; |
||||
} |
||||
|
||||
EAPI int |
||||
e_modapi_shutdown(E_Module *m)
|
||||
{ |
||||
mail_config->module = NULL; |
||||
e_gadcon_provider_unregister(&_gc_class); |
||||
|
||||
if (mail_config->config_dialog) |
||||
e_object_del(E_OBJECT(mail_config->config_dialog)); |
||||
if (mail_config->menu)
|
||||
{ |
||||
e_menu_post_deactivate_callback_set(mail_config->menu, NULL, NULL); |
||||
e_object_del(E_OBJECT(mail_config->menu)); |
||||
mail_config->menu = NULL; |
||||
} |
||||
while (mail_config->items)
|
||||
{ |
||||
Config_Item *ci; |
||||
|
||||
ci = mail_config->items->data; |
||||
if (ci->id) evas_stringshare_del(ci->id); |
||||
if (ci->host) evas_stringshare_del(ci->host); |
||||
if (ci->user) evas_stringshare_del(ci->user); |
||||
if (ci->pass) evas_stringshare_del(ci->pass); |
||||
if (ci->exec) evas_stringshare_del(ci->exec); |
||||
if (ci->path) evas_stringshare_del(ci->path); |
||||
if (ci->path_current) evas_stringshare_del(ci->path_current);
|
||||
mail_config->items = evas_list_remove_list(mail_config->items, mail_config->items); |
||||
free(ci); |
||||
} |
||||
free(mail_config); |
||||
mail_config = NULL; |
||||
E_CONFIG_DD_FREE(conf_item_edd); |
||||
E_CONFIG_DD_FREE(conf_edd); |
||||
return 1; |
||||
} |
||||
|
||||
EAPI int |
||||
e_modapi_save(E_Module *m)
|
||||
{ |
||||
Evas_List *l; |
||||
|
||||
for (l = mail_config->instances; l; l = l->next)
|
||||
{ |
||||
Instance *inst; |
||||
Config_Item *ci; |
||||
|
||||
inst = l->data; |
||||
ci = _mail_config_item_get(inst->gcc->id); |
||||
if (ci->id) evas_stringshare_del(ci->id); |
||||
ci->id = evas_stringshare_add(inst->gcc->id); |
||||
} |
||||
e_config_domain_save("module.mail", conf_edd, mail_config); |
||||
return 1; |
||||
} |
||||
|
||||
EAPI int |
||||
e_modapi_about(E_Module *m)
|
||||
{ |
||||
e_module_dialog_show(D_("Enlightenment Mail Module"),
|
||||
D_("This is a module to notify when you have new mail.")); |
||||
return 1; |
||||
} |
||||
|
||||
static Mail * |
||||
_mail_new(Evas *evas) |
||||
{ |
||||
Mail *mail; |
||||
char buf[4096]; |
||||
|
||||
mail = E_NEW(Mail, 1); |
||||
mail->mail_obj = edje_object_add(evas); |
||||
|
||||
snprintf(buf, sizeof(buf), "%s/mail.edj", e_module_dir_get(mail_config->module)); |
||||
if (!e_theme_edje_object_set(mail->mail_obj, "base/theme/modules/mail", "modules/mail/main")) |
||||
edje_object_file_set(mail->mail_obj, buf, "modules/mail/main"); |
||||
evas_object_show(mail->mail_obj); |
||||
|
||||
return mail; |
||||
} |
||||
|
||||
static void |
||||
_mail_free(Mail *mail)
|
||||
{ |
||||
evas_object_del(mail->mail_obj); |
||||
free(mail); |
||||
} |
||||
|
||||
static int
|
||||
_mail_cb_check(void *data)
|
||||
{ |
||||
Instance *inst; |
||||
Config_Item *ci; |
||||
|
||||
inst = data; |
||||
ci = _mail_config_item_get(inst->gcc->id); |
||||
if ((!ci->host) || (!ci->user) || (!ci->pass)) return 0; |
||||
|
||||
if (inst->server) ecore_con_server_del(inst->server); |
||||
inst->server = NULL; |
||||
|
||||
if ((ci->host) && (ci->port != 0))
|
||||
{
|
||||
inst->server = ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, ci->host, ci->port, inst); |
||||
inst->state = STATE_DISCONNECTED; |
||||
} |
||||
return 1; |
||||
} |
||||
|
||||
static int
|
||||