2012-04-01 [colin] 3.8.0cvs36

* configure.ac
	* src/.cvsignore
	* src/Makefile.am
	* src/addr_compl.c
	* src/addressadd.c
	* src/addressadd.h
	* src/addressbook-dbus.c
	* src/addressbook-dbus.h
	* src/addrgather.c
	* src/addrgather.h
	* src/addrharvest.c
	* src/addrharvest.h
	* src/claws-contacts.xml
	* src/compose.c
	* src/compose.h
	* src/filtering.c
	* src/headerview.c
	* src/main.c
	* src/mainwindow.c
	* src/messageview.c
	* src/prefs_common.c
	* src/prefs_filtering_action.c
	* src/prefs_matcher.c
	* src/summaryview.c
	* src/textview.c
	* src/toolbar.c
	* src/plugins/bogofilter/bogofilter_gtk.c
	* src/plugins/dillo_viewer/dillo_prefs.c
	* src/plugins/spamassassin/spamassassin_gtk.c
	* src/plugins/trayicon/trayicon.c
		Import new addressbook code from the new-contacts branch
This commit is contained in:
Colin Leroy 2012-04-01 18:45:27 +00:00
parent 059396f814
commit 11b84add9a
32 changed files with 1491 additions and 267 deletions

View file

@ -1,3 +1,37 @@
2012-04-01 [colin] 3.8.0cvs36
* configure.ac
* src/.cvsignore
* src/Makefile.am
* src/addr_compl.c
* src/addressadd.c
* src/addressadd.h
* src/addressbook-dbus.c
* src/addressbook-dbus.h
* src/addrgather.c
* src/addrgather.h
* src/addrharvest.c
* src/addrharvest.h
* src/claws-contacts.xml
* src/compose.c
* src/compose.h
* src/filtering.c
* src/headerview.c
* src/main.c
* src/mainwindow.c
* src/messageview.c
* src/prefs_common.c
* src/prefs_filtering_action.c
* src/prefs_matcher.c
* src/summaryview.c
* src/textview.c
* src/toolbar.c
* src/plugins/bogofilter/bogofilter_gtk.c
* src/plugins/dillo_viewer/dillo_prefs.c
* src/plugins/spamassassin/spamassassin_gtk.c
* src/plugins/trayicon/trayicon.c
Import new addressbook code from the new-contacts branch
2012-03-29 [paul] 3.8.0cvs35
* AUTHORS

View file

@ -4352,3 +4352,4 @@
( cvs diff -u -r 1.94.2.229 -r 1.94.2.230 src/messageview.c; cvs diff -u -r 1.96.2.238 -r 1.96.2.239 src/textview.c; ) > 3.8.0cvs33.patchset
( cvs diff -u -r 1.13.2.43 -r 1.13.2.44 src/common/plugin.c; ) > 3.8.0cvs34.patchset
( cvs diff -u -r 1.100.2.82 -r 1.100.2.83 AUTHORS; cvs diff -u -r 1.1.2.77 -r 1.1.2.78 src/gtk/authors.h; cvs diff -u -r 1.1.2.107 -r 1.1.2.108 src/gtk/quicksearch.c; ) > 3.8.0cvs35.patchset
( cvs diff -u -r 1.654.2.4430 -r 1.654.2.4431 configure.ac; cvs diff -u -r 1.11.2.2 -r 1.11.2.3 src/.cvsignore; cvs diff -u -r 1.155.2.98 -r 1.155.2.99 src/Makefile.am; cvs diff -u -r 1.27.2.60 -r 1.27.2.61 src/addr_compl.c; cvs diff -u -r 1.9.2.34 -r 1.9.2.35 src/addressadd.c; cvs diff -u -r 1.2.16.8 -r 1.2.16.9 src/addressadd.h; diff -u /dev/null src/addressbook-dbus.c; diff -u /dev/null src/addressbook-dbus.h; cvs diff -u -r 1.5.10.36 -r 1.5.10.37 src/addrgather.c; cvs diff -u -r 1.3.12.7 -r 1.3.12.8 src/addrgather.h; cvs diff -u -r 1.6.10.25 -r 1.6.10.26 src/addrharvest.c; cvs diff -u -r 1.4.12.8 -r 1.4.12.9 src/addrharvest.h; diff -u /dev/null src/claws-contacts.xml; cvs diff -u -r 1.382.2.598 -r 1.382.2.599 src/compose.c; cvs diff -u -r 1.50.2.65 -r 1.50.2.66 src/compose.h; cvs diff -u -r 1.60.2.61 -r 1.60.2.62 src/filtering.c; cvs diff -u -r 1.8.2.34 -r 1.8.2.35 src/headerview.c; cvs diff -u -r 1.115.2.247 -r 1.115.2.248 src/main.c; cvs diff -u -r 1.274.2.343 -r 1.274.2.344 src/mainwindow.c; cvs diff -u -r 1.94.2.230 -r 1.94.2.231 src/messageview.c; cvs diff -u -r 1.204.2.208 -r 1.204.2.209 src/prefs_common.c; cvs diff -u -r 1.1.4.73 -r 1.1.4.74 src/prefs_filtering_action.c; cvs diff -u -r 1.43.2.91 -r 1.43.2.92 src/prefs_matcher.c; cvs diff -u -r 1.395.2.445 -r 1.395.2.446 src/summaryview.c; cvs diff -u -r 1.96.2.239 -r 1.96.2.240 src/textview.c; cvs diff -u -r 1.43.2.126 -r 1.43.2.127 src/toolbar.c; cvs diff -u -r 1.1.2.40 -r 1.1.2.41 src/plugins/bogofilter/bogofilter_gtk.c; cvs diff -u -r 1.5.2.27 -r 1.5.2.28 src/plugins/dillo_viewer/dillo_prefs.c; cvs diff -u -r 1.23.2.57 -r 1.23.2.58 src/plugins/spamassassin/spamassassin_gtk.c; cvs diff -u -r 1.14.2.79 -r 1.14.2.80 src/plugins/trayicon/trayicon.c; ) > 3.8.0cvs36.patchset

View file

@ -12,7 +12,7 @@ MINOR_VERSION=8
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
EXTRA_VERSION=35
EXTRA_VERSION=36
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
@ -142,6 +142,7 @@ AM_CONDITIONAL(CYGWIN, test x"$env_cygwin" = x"yes")
if test "$GCC" = "yes"
then
CFLAGS="$CFLAGS -Wno-unused-function"
#CFLAGS="-g -Wall -Wno-unused-function"
fi
AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
@ -478,7 +479,7 @@ if test x"$ac_cv_enable_gtk3" = x"yes"; then
AM_CONDITIONAL(GTK3, true)
AM_CONDITIONAL(GTK2, false)
else
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.16)
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.18)
dnl --disable-deprecated switch for GTK2 purification
AC_ARG_ENABLE(deprecated, [ --disable-deprecated disable deprecated GTK functions. ],
@ -649,116 +650,6 @@ fi
AC_SUBST(LIBRESOLV)
LIBS="$LIBS $LIBRESOLV"
dnl for LDAP support in addressbook
dnl no check for libraries; dynamically loaded
AC_ARG_ENABLE(ldap,
[ --disable-ldap disable LDAP support],
[ac_cv_enable_ldap=$enableval], [ac_cv_enable_ldap=yes])
AC_MSG_CHECKING([whether to use LDAP])
if test x"$ac_cv_enable_ldap" = xno; then
AC_MSG_RESULT(no)
elif test x"$ac_cv_enable_ldap" = xyes -a x"$ac_cv_enable_pthread" = xno; then
AC_MSG_RESULT(no - LDAP support needs pthread support)
ac_cv_enable_ldap=no
elif test x"$platform_win32" = xyes; then
AC_MSG_RESULT(yes)
AC_DEFINE(USE_LDAP, 1, Define if you want LDAP support in addressbook.)
LDAP_LIBS="-lwldap32"
AC_SUBST(LDAP_LIBS)
else
AC_MSG_RESULT(yes)
dnl check for available libraries, and pull them in
AC_CHECK_LIB(resolv, res_query, LDAP_LIBS="$LDAP_LIBS -lresolv")
AC_CHECK_LIB(socket, bind, LDAP_LIBS="$LDAP_LIBS -lsocket")
AC_CHECK_LIB(nsl, gethostbyaddr, LDAP_LIBS="$LDAP_LIBS -lnsl")
AC_CHECK_LIB(lber, ber_get_tag, LDAP_LIBS="$LDAP_LIBS -llber",,
$LDAP_LIBS)
AC_CHECK_HEADERS(ldap.h lber.h,
[ ac_cv_enable_ldap=yes ],
[ ac_cv_enable_ldap=no ])
if test "$ac_cv_enable_ldap" = yes; then
AC_CHECK_LIB(ldap, ldap_open,
[ ac_cv_enable_ldap=yes ],
[ ac_cv_enable_ldap=no ],
$LDAP_LIBS)
AC_CHECK_LIB(ldap, ldap_start_tls_s,
[ ac_cv_have_tls=yes ],
[ ac_cv_have_tls=no ])
fi
AC_MSG_CHECKING([whether ldap library is available])
AC_MSG_RESULT($ac_cv_enable_ldap)
AC_MSG_CHECKING([whether TLS library is available])
AC_MSG_RESULT($ac_cv_have_tls)
if test "$ac_cv_enable_ldap" = yes; then
AC_DEFINE(USE_LDAP, 1, Define if you want LDAP support in addressbook.)
LDAP_LIBS="$LDAP_LIBS -lldap"
AC_SUBST(LDAP_LIBS)
if test "$ac_cv_have_tls" = yes; then
AC_DEFINE(USE_LDAP_TLS, 1, Define if you want LDAP TLS support in addressbook.)
fi
dnl As of OpenLDAP API version 3000 a number of functions has
dnl been deprecated. As Claws-mail compiles and runs on many
dnl platforms and many versions of OpenLDAP we need to be able
dnl to switch between the old and new API because new API has
dnl added new functions replacing old ones and at the same time
dnl old functions has been changed.
dnl If cross-compiling defaults to enable deprecated features
dnl for maximum portability
AC_MSG_CHECKING([The API version of OpenLDAP])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[#include <ldap.h>],
[if (LDAP_API_VERSION >= 3000)
return 1
])],
[AC_MSG_RESULT([version < 3000])
AC_DEFINE(OPEN_LDAP_API_AT_LEAST_3000, 0, Define if OpenLDAP API is at least version 3000.)],
[AC_MSG_RESULT([version >= 3000])
AC_DEFINE(OPEN_LDAP_API_AT_LEAST_3000, 1, Define if OpenLDAP API is at least version 3000.)],
[AC_MSG_RESULT([Enabling deprecated features in OpenLDAP])
AC_DEFINE(OPEN_LDAP_API_AT_LEAST_3000, 0, Define if OpenLDAP API is at least version 3000.)
AC_DEFINE(LDAP_DEPRECATED, 1, Define to activate deprecated features in OpenLDAP)]
)
fi
fi
dnl for JPilot support in addressbook
dnl no check for libraries; these are dynamically loaded
AC_ARG_ENABLE(jpilot,
[ --disable-jpilot disable JPilot support],
[ac_cv_enable_jpilot=$enableval], [ac_cv_enable_jpilot=yes])
AC_MSG_CHECKING([whether to use JPilot])
if test "$ac_cv_enable_jpilot" = yes; then
AC_MSG_RESULT(yes)
AC_CHECK_HEADERS(pi-args.h pi-appinfo.h pi-address.h pi-version.h,
[ AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ],
[ ac_cv_enable_jpilot=no ])
if test "$ac_cv_enable_jpilot" = no; then
AC_CHECK_HEADERS(libpisock/pi-args.h libpisock/pi-appinfo.h libpisock/pi-address.h libpisock/pi-version.h,
[ ac_cv_enable_jpilot=yes
AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ])
fi
AC_CHECK_LIB(pisock, unpack_Address, [JPILOT_LIBS="-lpisock"], [JPILOT_LIBS="" ac_cv_enable_jpilot="no"])
if test x"$ac_cv_enable_jpilot" = xyes; then
AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.)
else
AC_MSG_NOTICE([JPilot support not available])
fi
AC_SUBST(JPILOT_LIBS)
else
AC_MSG_RESULT(no)
fi
dnl #######################################################################
dnl # Check for startup notification
@ -800,6 +691,156 @@ if test "x$enable_dbus" = "xyes"; then
AC_SUBST(DBUS_LIBS)
fi
dnl #######################################################################
dnl # Configure address book support
dnl #######################################################################
dnl #######################################################################
dnl # Check for new address book support
dnl #######################################################################
AC_MSG_CHECKING([whether DBUS support for new address book is present])
if test x"$enable_dbus_glib" = xyes; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([whether to enable new address book])
AC_ARG_ENABLE(new-addrbook, [ --enable-new-addrbook enable new address book],,enable_new_addrbook=no)
if test x"$enable_new_addrbook" = xyes; then
AC_MSG_RESULT([yes])
PKG_CHECK_MODULES(CONTACTS, [claws-contacts],
[
AC_DEFINE(USE_NEW_ADDRBOOK, 1, [Define if new address book is to be activated.])
enable_new_addrbook=yes
AC_SUBST(CONTACTS_CFLAGS)
AC_SUBST(CONTACTS_LIBS)
],
[
enable_new_addrbook=no
])
else
AC_MSG_RESULT([no])
enable_new_addrbook=no
fi
else
AC_MSG_RESULT([no])
enable_new_addrbook=no
fi
dnl #######################################################################
dnl # Check for old address book support
dnl #######################################################################
if test x"$enable_new_addrbook" = xno; then
dnl for LDAP support in addressbook
dnl no check for libraries; dynamically loaded
AC_ARG_ENABLE(ldap,
[ --disable-ldap disable LDAP support],
[ac_cv_enable_ldap=$enableval], [ac_cv_enable_ldap=yes])
AC_MSG_CHECKING([whether to use LDAP])
if test x"$ac_cv_enable_ldap" = xno; then
AC_MSG_RESULT(no)
elif test x"$ac_cv_enable_ldap" = xyes -a x"$ac_cv_enable_pthread" = xno; then
AC_MSG_RESULT(no - LDAP support needs pthread support)
ac_cv_enable_ldap=no
elif test x"$platform_win32" = xyes; then
AC_MSG_RESULT(yes)
AC_DEFINE(USE_LDAP, 1, Define if you want LDAP support in addressbook.)
LDAP_LIBS="-lwldap32"
AC_SUBST(LDAP_LIBS)
else
AC_MSG_RESULT(yes)
dnl check for available libraries, and pull them in
AC_CHECK_LIB(resolv, res_query, LDAP_LIBS="$LDAP_LIBS -lresolv")
AC_CHECK_LIB(socket, bind, LDAP_LIBS="$LDAP_LIBS -lsocket")
AC_CHECK_LIB(nsl, gethostbyaddr, LDAP_LIBS="$LDAP_LIBS -lnsl")
AC_CHECK_LIB(lber, ber_get_tag, LDAP_LIBS="$LDAP_LIBS -llber",,
$LDAP_LIBS)
AC_CHECK_HEADERS(ldap.h lber.h,
[ ac_cv_enable_ldap=yes ],
[ ac_cv_enable_ldap=no ])
if test "$ac_cv_enable_ldap" = yes; then
AC_CHECK_LIB(ldap, ldap_open,
[ ac_cv_enable_ldap=yes ],
[ ac_cv_enable_ldap=no ],
$LDAP_LIBS)
AC_CHECK_LIB(ldap, ldap_start_tls_s,
[ ac_cv_have_tls=yes ],
[ ac_cv_have_tls=no ])
fi
AC_MSG_CHECKING([whether ldap library is available])
AC_MSG_RESULT($ac_cv_enable_ldap)
AC_MSG_CHECKING([whether TLS library is available])
AC_MSG_RESULT($ac_cv_have_tls)
if test "$ac_cv_enable_ldap" = yes; then
AC_DEFINE(USE_LDAP, 1, Define if you want LDAP support in addressbook.)
LDAP_LIBS="$LDAP_LIBS -lldap"
AC_SUBST(LDAP_LIBS)
if test "$ac_cv_have_tls" = yes; then
AC_DEFINE(USE_LDAP_TLS, 1, Define if you want LDAP TLS support in addressbook.)
fi
dnl As of OpenLDAP API version 3000 a number of functions has
dnl been deprecated. As Claws-mail compiles and runs on many
dnl platforms and many versions of OpenLDAP we need to be able
dnl to switch between the old and new API because new API has
dnl added new functions replacing old ones and at the same time
dnl old functions has been changed.
dnl If cross-compiling defaults to enable deprecated features
dnl for maximum portability
AC_MSG_CHECKING([The API version of OpenLDAP])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[#include <ldap.h>],
[if (LDAP_API_VERSION >= 3000)
return 1
])],
[AC_MSG_RESULT([version < 3000])
AC_DEFINE(OPEN_LDAP_API_AT_LEAST_3000, 0, Define if OpenLDAP API is at least version 3000.)],
[AC_MSG_RESULT([version >= 3000])
AC_DEFINE(OPEN_LDAP_API_AT_LEAST_3000, 1, Define if OpenLDAP API is at least version 3000.)],
[AC_MSG_RESULT([Enabling deprecated features in OpenLDAP])
AC_DEFINE(OPEN_LDAP_API_AT_LEAST_3000, 0, Define if OpenLDAP API is at least version 3000.)
AC_DEFINE(LDAP_DEPRECATED, 1, Define to activate deprecated features in OpenLDAP)]
)
fi
fi
dnl for JPilot support in addressbook
dnl no check for libraries; these are dynamically loaded
AC_ARG_ENABLE(jpilot,
[ --disable-jpilot disable JPilot support],
[ac_cv_enable_jpilot=$enableval], [ac_cv_enable_jpilot=yes])
AC_MSG_CHECKING([whether to use JPilot])
if test "$ac_cv_enable_jpilot" = yes; then
AC_MSG_RESULT(yes)
AC_CHECK_HEADERS(pi-args.h pi-appinfo.h pi-address.h pi-version.h,
[ AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ],
[ ac_cv_enable_jpilot=no ])
if test "$ac_cv_enable_jpilot" = no; then
AC_CHECK_HEADERS(libpisock/pi-args.h libpisock/pi-appinfo.h libpisock/pi-address.h libpisock/pi-version.h,
[ ac_cv_enable_jpilot=yes
AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.) ])
fi
AC_CHECK_LIB(pisock, unpack_Address, [JPILOT_LIBS="-lpisock"], [JPILOT_LIBS="" ac_cv_enable_jpilot="no"])
if test x"$ac_cv_enable_jpilot" = xyes; then
AC_DEFINE(USE_JPILOT, 1, Define if you want JPilot support in addressbook.)
else
AC_MSG_NOTICE([JPilot support not available])
fi
AC_SUBST(JPILOT_LIBS)
else
AC_MSG_RESULT(no)
fi
fi
AM_CONDITIONAL(BUILD_NEWADDRBOOK, test x"$enable_new_addrbook" = x"yes")
dnl #######################################################################
dnl # Check for NetworkManager support
dnl #######################################################################
@ -1098,24 +1139,29 @@ dnl Output the configuration summary
echo ""
echo "$PACKAGE $VERSION"
echo ""
echo "JPilot : $ac_cv_enable_jpilot"
echo "LDAP : $ac_cv_enable_ldap"
echo "gnuTLS : $ac_cv_enable_gnutls"
echo "iconv : $am_cv_func_iconv"
echo "compface : $ac_cv_enable_compface"
echo "IPv6 : $ac_cv_enable_ipv6"
echo "enchant : $ac_cv_enable_enchant"
echo "IMAP4 : $ac_cv_enable_libetpan"
echo "NNTP : $ac_cv_enable_libetpan"
echo "Crash dialog : $ac_cv_enable_crash_dialog"
echo "LibSM : $ac_cv_enable_libsm"
echo "DBUS : $enable_dbus"
echo "NetworkManager : $enable_networkmanager_support"
echo "Manual : $ac_cv_enable_manual"
echo "Plugins : $PLUGINS"
echo "Generic UMPC code : $ac_cv_enable_generic_umpc"
echo "Maemo build : $ac_cv_enable_maemo"
echo "Config dir : $ac_cv_with_config_dir"
if test x"$enable_new_addrbook" = xyes; then
echo "Using Address Book : New experimental interface"
else
echo "Using Address Book : Old stable interface"
echo "JPilot : $ac_cv_enable_jpilot"
echo "LDAP : $ac_cv_enable_ldap"
fi
echo "gnuTLS : $ac_cv_enable_gnutls"
echo "iconv : $am_cv_func_iconv"
echo "compface : $ac_cv_enable_compface"
echo "IPv6 : $ac_cv_enable_ipv6"
echo "enchant : $ac_cv_enable_enchant"
echo "IMAP4 : $ac_cv_enable_libetpan"
echo "NNTP : $ac_cv_enable_libetpan"
echo "Crash dialog : $ac_cv_enable_crash_dialog"
echo "LibSM : $ac_cv_enable_libsm"
echo "DBUS : $enable_dbus"
echo "NetworkManager : $enable_networkmanager_support"
echo "Manual : $ac_cv_enable_manual"
echo "Plugins : $PLUGINS"
echo "Generic UMPC code : $ac_cv_enable_generic_umpc"
echo "Maemo build : $ac_cv_enable_maemo"
echo "Config dir : $ac_cv_with_config_dir"
echo ""
echo "The binary will be installed in $prefix/bin"
echo ""

View file

@ -13,3 +13,4 @@ matcher_parser_lex.c
matcher_parser_parse.c
matcher_parser_parse.h
ylwrap
client-bindings.h

View file

@ -29,32 +29,61 @@ claws_mail_res_ldflag =
claws_mail_deps =
endif
claws_mail_SOURCES = \
account.c \
action.c \
if BUILD_NEWADDRBOOK
abook_headers = \
addressbook-dbus.h
abook_source = \
addressbook-dbus.c
else
abook_headers = \
addrbook.h \
addrclip.h \
addrcustomattr.h \
addressbook.h \
addressbook_foldersel.h \
addrindex.h \
addrquery.h \
addrselect.h \
addrduplicates.h \
browseldap.h \
editaddress.h \
editaddress_other_attributes_ldap.h \
editbook.h \
editgroup.h \
editjpilot.h \
editldap_basedn.h \
editldap.h \
editvcard.h \
exphtmldlg.h \
expldifdlg.h \
exporthtml.h \
exportldif.h \
importldif.h \
importmutt.h \
importpine.h \
jpilot.h \
ldapctrl.h \
ldaplocate.h \
ldapquery.h \
ldapserver.h \
ldapupdate.h \
ldaputil.h \
ldif.h \
mutt.h \
pine.h \
vcard.h
abook_source = \
addrbook.c \
addrcache.c \
addrclip.c \
addr_compl.c \
addrcustomattr.c \
addressadd.c \
addressbook.c \
addressbook_foldersel.c \
addrgather.c \
addrharvest.c \
addrindex.c \
addritem.c \
addrquery.c \
addrselect.c \
addrduplicates.c \
alertpanel.c \
autofaces.c \
browseldap.c \
codeconv.c \
compose.c \
crash.c \
customheader.c \
displayheader.c \
editaddress.c \
editaddress_other_attributes_ldap.c \
editbook.c \
@ -62,14 +91,46 @@ claws_mail_SOURCES = \
editjpilot.c \
editldap_basedn.c \
editldap.c \
edittags.c \
editvcard.c \
enriched.c \
exphtmldlg.c \
expldifdlg.c \
export.c \
exporthtml.c \
exportldif.c \
importldif.c \
importmutt.c \
importpine.c \
jpilot.c \
ldapctrl.c \
ldaplocate.c \
ldapquery.c \
ldapserver.c \
ldapupdate.c \
ldaputil.c \
ldif.c \
mutt.c \
pine.c \
vcard.c
endif
claws_mail_SOURCES = \
account.c \
action.c \
addrcache.c \
addr_compl.c \
addressadd.c \
addrgather.c \
addrharvest.c \
addritem.c \
alertpanel.c \
autofaces.c \
codeconv.c \
compose.c \
crash.c \
customheader.c \
displayheader.c \
edittags.c \
enriched.c \
export.c \
filtering.c \
folder.c \
folder_item_prefs.c \
@ -83,18 +144,7 @@ claws_mail_SOURCES = \
imap.c \
imap_gtk.c \
import.c \
importldif.c \
importmutt.c \
importpine.c \
inc.c \
jpilot.c \
ldapctrl.c \
ldaplocate.c \
ldapquery.c \
ldapserver.c \
ldapupdate.c \
ldaputil.c \
ldif.c \
localfolder.c \
main.c \
mainwindow.c \
@ -109,12 +159,10 @@ claws_mail_SOURCES = \
mh_gtk.c \
mimeview.c \
msgcache.c \
mutt.c \
news.c \
news_gtk.c \
noticeview.c \
partial_download.c \
pine.c \
pop.c \
prefs_account.c \
prefs_actions.c \
@ -170,54 +218,31 @@ claws_mail_SOURCES = \
undo.c \
unmime.c \
uri_opener.c \
vcard.c \
wizard.c
wizard.c \
$(abook_source)
claws_mailincludedir = $(pkgincludedir)
claws_mailinclude_HEADERS = \
account.h \
action.h \
adbookbase.h \
addrbook.h \
addrcache.h \
addrclip.h \
addr_compl.h \
addrdefs.h \
addrcustomattr.h \
addressadd.h \
addressbook.h \
addressbook_foldersel.h \
addritem.h \
addressitem.h \
addrgather.h \
addrharvest.h \
addrindex.h \
addritem.h \
addrquery.h \
addrselect.h \
addrduplicates.h \
alertpanel.h \
autofaces.h \
browseldap.h \
codeconv.h \
compose.h \
crash.h \
customheader.h \
displayheader.h \
editaddress.h \
editaddress_other_attributes_ldap.h \
editbook.h \
editgroup.h \
editjpilot.h \
editldap_basedn.h \
editldap.h \
edittags.h \
editvcard.h \
enriched.h \
exphtmldlg.h \
expldifdlg.h \
export.h \
exporthtml.h \
exportldif.h \
filtering.h \
folder.h \
folder_item_prefs.h \
@ -231,18 +256,7 @@ claws_mailinclude_HEADERS = \
imap.h \
imap_gtk.h \
import.h \
importldif.h \
importmutt.h \
importpine.h \
inc.h \
jpilot.h \
ldapctrl.h \
ldaplocate.h \
ldapquery.h \
ldapserver.h \
ldapupdate.h \
ldaputil.h \
ldif.h \
localfolder.h \
main.h \
mainwindow.h \
@ -258,12 +272,10 @@ claws_mailinclude_HEADERS = \
mh_gtk.h \
mimeview.h \
msgcache.h \
mutt.h \
news.h \
news_gtk.h \
noticeview.h \
partial_download.h \
pine.h \
pop.h \
prefs_account.h \
prefs_actions.h \
@ -318,12 +330,21 @@ claws_mailinclude_HEADERS = \
undo.h \
unmime.h \
uri_opener.h \
vcard.h \
wizard.h
wizard.h \
$(abook_headers)
BUILT_SOURCES = \
matcher_parser_parse.h \
quote_fmt_parse.h
quote_fmt_parse.h \
client-bindings.h
client-bindings.h: claws-contacts.xml
if BUILD_NEWADDRBOOK
dbus-binding-tool --prefix=abook --mode=glib-client --output=$@ claws-contacts.xml
CLEANFILES = \
client-bindings.h
endif
EXTRA_DIST = \
w32-logo.ico w32-resource.rc \
@ -488,7 +509,8 @@ EXTRA_DIST = \
pixmaps/tray_unreadmarkedmail.offline.xpm \
pixmaps/tray_unreadmarkedmail.xpm \
pixmaps/empty.xpm \
pixmaps/replied_and_forwarded.xpm
pixmaps/replied_and_forwarded.xpm \
claws-contacts.xml
INCLUDES = \
@ -528,7 +550,8 @@ claws_mail_LDADD = \
$(LIBETPAN_LIBS) \
$(MAEMO_LIBS) \
$(CONIC_LIBS) \
$(DBUS_LIBS)
$(DBUS_LIBS) \
$(CONTACTS_LIBS)
pixmapdir=$(datadir)/icons/hicolor/48x48/apps
@ -550,7 +573,8 @@ AM_CPPFLAGS = \
$(CONIC_CFLAGS) \
$(DBUS_CFLAGS) \
$(NETWORKMANAGER_SUPPORT_CFLAGS) \
$(VALGRIND_CFLAGS)
$(VALGRIND_CFLAGS) \
$(CONTACTS_CFLAGS)
#no-unused-function is there because of bison stuff
#no-deprecated-declarations because of gpgme_data_rewind, which we have

View file

@ -35,8 +35,8 @@
# include <wctype.h>
#endif
#include "addrindex.h"
#include "addr_compl.h"
#include "addritem.h"
#include "utils.h"
#include "prefs_common.h"
#include "claws.h"
@ -44,6 +44,12 @@
#include "gtkutils.h"
#include <pthread.h>
#ifndef USE_NEW_ADDRBOOK
#include "addrindex.h"
#else
#include "addressbook-dbus.h"
#endif
/*!
*\brief For the GtkListStore
*/
@ -286,8 +292,18 @@ static void read_address_book(gchar *folderpath) {
free_all_addresses();
free_completion_list();
#ifndef USE_NEW_ADDRBOOK
addrindex_load_completion( add_address, folderpath );
#else
GError* error = NULL;
addrcompl_initialize();
if (! addrindex_dbus_load_completion(add_address, &error)) {
g_warning("Failed to populate address completion list");
g_error_free(error);
return;
}
#endif
/* plugins may hook in here to modify/extend the completion list */
hooks_invoke(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, &g_address_list);
@ -753,8 +769,9 @@ static CompletionWindow *addrcompl_create_window( void ) {
*/
static void addrcompl_destroy_window( CompletionWindow *cw ) {
/* Stop all searches currently in progress */
#ifndef USE_NEW_ADDRBOOK
addrindex_stop_search( _queryID_ );
#endif
/* Remove idler function... or application may not terminate */
if( _completionIdleID_ != 0 ) {
g_source_remove( _completionIdleID_ );
@ -975,6 +992,7 @@ static gboolean addrcompl_idle( gpointer data ) {
* criteria.
* \param data Query data.
*/
#ifndef USE_NEW_ADDRBOOK
static gint addrcompl_callback_entry(
gpointer sender, gint queryID, GList *listEMail, gpointer data )
{
@ -1000,6 +1018,7 @@ static gint addrcompl_callback_entry(
return 0;
}
#endif
/**
* Clear the display queue.
@ -1045,6 +1064,7 @@ static void addrcompl_load_local( void ) {
* Start the search.
*/
static void addrcompl_start_search( void ) {
#ifndef USE_NEW_ADDRBOOK
gchar *searchTerm;
searchTerm = g_strdup( _compWindow_->searchTerm );
@ -1053,6 +1073,7 @@ static void addrcompl_start_search( void ) {
_queryID_ = addrindex_setup_search(
searchTerm, NULL, addrcompl_callback_entry );
g_free( searchTerm );
#endif
/* g_print( "addrcompl_start_search::queryID=%d\n", _queryID_ ); */
/* Load local stuff */
@ -1063,7 +1084,11 @@ static void addrcompl_start_search( void ) {
g_idle_add( (GSourceFunc) addrcompl_idle, NULL );
/* g_print( "addrindex_start_search::queryID=%d\n", _queryID_ ); */
#ifndef USE_NEW_ADDRBOOK
addrindex_start_search( _queryID_ );
#else
#endif
}
/**

View file

@ -37,18 +37,28 @@
#include "prefs_common.h"
#include "prefs_gtk.h"
#include "addressadd.h"
#include "addritem.h"
#include "addrbook.h"
#include "addrindex.h"
#ifndef USE_NEW_ADDRBOOK
#include "addritem.h"
#include "addrbook.h"
#include "addrindex.h"
#include "ldapserver.h"
#include "ldapupdate.h"
#else
#include "addressbook-dbus.h"
#endif
#include "manage_window.h"
#include "ldapserver.h"
#include "ldapupdate.h"
#include "alertpanel.h"
#ifndef USE_NEW_ADDRBOOK
typedef struct {
AddressBookFile *book;
ItemFolder *folder;
} FolderInfo;
#else
typedef struct {
gchar* book;
} FolderInfo;
#endif
static struct _AddressAdd_dlg {
GtkWidget *window;
@ -67,6 +77,7 @@ static GdkPixbuf *bookXpm;
static gboolean addressadd_cancelled;
#ifndef USE_NEW_ADDRBOOK
static FolderInfo *addressadd_create_folderinfo( AddressBookFile *abf, ItemFolder *folder )
{
FolderInfo *fi = g_new0( FolderInfo, 1 );
@ -74,12 +85,26 @@ static FolderInfo *addressadd_create_folderinfo( AddressBookFile *abf, ItemFolde
fi->folder = folder;
return fi;
}
#else
static FolderInfo *addressadd_create_folderinfo(gchar* book) {
FolderInfo *fi = g_new0( FolderInfo, 1 );
fi->book = book;
return fi;
}
#endif
#ifndef USE_NEW_ADDRBOOK
static void addressadd_free_folderinfo( FolderInfo *fi ) {
fi->book = NULL;
fi->folder = NULL;
g_free( fi );
}
#else
static void addressadd_free_folderinfo( FolderInfo *fi ) {
fi->book = NULL;
g_free( fi );
}
#endif
static gint addressadd_delete_event( GtkWidget *widget, GdkEventAny *event, gboolean *cancelled ) {
addressadd_cancelled = TRUE;
@ -284,6 +309,7 @@ static void addressadd_create( void ) {
&folderXpm );
}
#ifndef USE_NEW_ADDRBOOK
static void addressadd_load_folder( GtkCMCTreeNode *parentNode, ItemFolder *parentFolder,
FolderInfo *fiParent )
{
@ -361,18 +387,51 @@ static void addressadd_load_data( AddressIndex *addrIndex ) {
list = g_list_next( list );
}
}
#else
static void addressadd_load_data() {
GSList *list;
gchar *name;
GtkCMCTree *tree = GTK_CMCTREE(addressadd_dlg.tree_folder);
GtkCMCTreeNode *node;
FolderInfo *fi = NULL;
GError* error = NULL;
gtk_cmclist_clear(GTK_CMCLIST(tree));
list = addressbook_dbus_get_books(&error);
for (; list; list = g_slist_next(list)) {
name = (gchar *) list->data;
node = gtk_cmctree_insert_node(tree, NULL, NULL,
&name, FOLDER_SPACING, bookXpm,
bookXpm, FALSE, TRUE);
fi = addressadd_create_folderinfo(name);
gtk_cmctree_node_set_row_data_full(tree, node, fi,
( GDestroyNotify ) addressadd_free_folderinfo );
}
}
#endif
#ifndef USE_NEW_ADDRBOOK
gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name,
const gchar *address, const gchar *remarks, GdkPixbuf *picture ) {
#else
gboolean addressadd_selection(const gchar *name, const gchar *address,
const gchar *remarks, GdkPixbuf *picture ) {
#endif
gboolean retVal = FALSE;
#ifndef USE_NEW_ADDRBOOK
ItemPerson *person = NULL;
#endif
FolderInfo *fi = NULL;
addressadd_cancelled = FALSE;
if( ! addressadd_dlg.window ) addressadd_create();
addressadd_dlg.fiSelected = NULL;
#ifndef USE_NEW_ADDRBOOK
addressadd_load_data( addrIndex );
#else
addressadd_load_data();
#endif
gtk_cmclist_select_row( GTK_CMCLIST( addressadd_dlg.tree_folder ), 0, 0 );
gtk_widget_show(addressadd_dlg.window);
gtk_window_set_modal(GTK_WINDOW(addressadd_dlg.window), TRUE);
@ -407,6 +466,7 @@ gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name,
fi = addressadd_dlg.fiSelected;
#ifndef USE_NEW_ADDRBOOK
person = addrbook_add_contact( fi->book, fi->folder,
returned_name,
address,
@ -426,6 +486,42 @@ gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name,
addritem_person_set_picture( person, ADDRITEM_ID(person) ) ;
g_free( name );
}
#else
ContactData* contact = g_new0(ContactData, 1);
GError* error = NULL;
if (returned_name)
contact->cn = g_strdup(returned_name);
else
contact->cn = g_strdup(address);
contact->name = g_strdup(returned_name);
contact->email = g_strdup(address);
contact->remarks = g_strdup(returned_remarks);
contact->book = g_strdup(fi->book);
contact->picture = picture;
if (addressbook_dbus_add_contact(contact, &error) == 0) {
debug_print("Added to addressbook:\n%s\n%s\n%s\n%s\n",
returned_name, address, returned_remarks, fi->book);
retVal = TRUE;
}
else {
retVal = FALSE;
if (error) {
GtkWidget* dialog = gtk_message_dialog_new (
GTK_WINDOW(addressadd_dlg.window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"%s", error->message);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_error_free(error);
}
}
contact_data_free(&contact);
#endif
#ifdef USE_LDAP
if (fi->book->type == ADBOOKTYPE_LDAP) {
LdapServer *server = (LdapServer *) fi->book;
@ -441,7 +537,9 @@ gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name,
#endif
g_free(returned_name);
g_free(returned_remarks);
#ifndef USE_NEW_ADDRBOOK
if( person ) retVal = TRUE;
#endif
}
}

View file

@ -24,10 +24,17 @@
#ifndef __ADDRESS_ADD_H__
#define __ADDRESS_ADD_H__
#include "addrindex.h"
#ifndef USE_NEW_ADDRBOOK
#include "addrindex.h"
#endif
#include "gtk/gtk.h"
#ifndef USE_NEW_ADDRBOOK
gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name, const gchar *address, const gchar *remarks,
GdkPixbuf *picture );
#else
gboolean addressadd_selection(const gchar *name, const gchar *address, const gchar *remarks,
GdkPixbuf *picture );
#endif
#endif /* __ADDRESS_ADD_H__ */

487
src/addressbook-dbus.c Normal file
View file

@ -0,0 +1,487 @@
/*
* $Id$
*/
/* vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: */
/*
* Claws-contacts is a proposed new design for the address book feature
* in Claws Mail. The goal for this new design was to create a
* solution more suitable for the term lightweight and to be more
* maintainable than the present implementation.
*
* More lightweight is achieved by design, in that sence that the whole
* structure is based on a plugable design.
*
* Claws Mail is Copyright (C) 1999-2011 by the Claws Mail Team and
* Claws-contacts is Copyright (C) 2011 by Michael Rasmussen.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-bindings.h>
#include "dbus-contact.h"
#include "addrgather.h"
#include "folder.h"
#include "compose.h"
#include "hooks.h"
#include "addressbook-dbus.h"
#include "client-bindings.h"
static DBusGProxy* proxy = NULL;
static DBusGConnection* connection = NULL;
static Compose* compose_instance = NULL;
static GQuark client_object_error_quark() {
static GQuark quark = 0;
if (!quark)
quark = g_quark_from_static_string ("client_object_error");
return quark;
}
static gboolean init(GError** error) {
connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
if (connection == NULL || *error) {
if (! *error)
g_set_error(error, client_object_error_quark(), 1, "Unable to connect to dbus");
g_warning("Unable to connect to dbus: %s\n", (*error)->message);
return FALSE;
}
proxy = dbus_g_proxy_new_for_name (connection,
"org.clawsmail.Contacts",
"/org/clawsmail/contacts",
"org.clawsmail.Contacts");
if (proxy == NULL) {
g_warning("Could not get a proxy object\n");
g_set_error(error, client_object_error_quark(), 1, "Could not get a proxy object");
return FALSE;
}
return TRUE;
}
static void dbus_contact_free(const DBusContact* contact) {
g_hash_table_destroy(contact->data);
g_ptr_array_free(contact->emails, TRUE);
}
static GHashTable* hash_table_new(void) {
GHashTable* hash_table;
hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
return hash_table;
}
static void g_value_email_free(gpointer data) {
GValueArray* email = (GValueArray *) data;
GValue* email_member;
guint i;
for (i = 0; i < email->n_values; i++) {
email_member = g_value_array_get_nth(email, i);
g_value_unset(email_member);
}
}
static GPtrArray* g_value_email_new() {
return g_ptr_array_new_with_free_func(g_value_email_free);
}
static gchar* convert_2_utf8(gchar* locale) {
gsize read, write;
GError* error = NULL;
gchar *current, *utf8;
const gchar* charset;
if (g_get_charset(&charset) || g_utf8_validate(locale, -1, 0))
return g_strdup(locale);
if (strcmp("ANSI_X3.4-1968", charset) == 0)
current = g_strdup("ISO-8859-1");
else
current = g_strdup(charset);
utf8 = g_convert(locale, -1, "UTF-8", current, &read, &write, &error);
if (error) {
g_warning("Fail to convert [%s]: %s\n", charset, error->message);
g_free(current);
return NULL;
}
g_free(current);
return utf8;
}
static void format_contact(DBusContact* contact, ContactData* c) {
gchar* firstname;
gchar* lastname;
GValueArray* email = NULL;
GValue email_member = {0};
gchar* str;
gchar* image = NULL;
gsize size;
contact->data = hash_table_new();
contact->emails = g_value_email_new();
firstname = lastname = NULL;
if (c->name) {
gchar* pos = strchr(c->name, ' ');
if (pos) {
firstname = g_strndup(c->name, pos - c->name);
lastname = g_strdup(++pos);
g_hash_table_replace(contact->data,
g_strdup("first-name"), convert_2_utf8(firstname));
g_hash_table_replace(contact->data,
g_strdup("last-name"), convert_2_utf8(lastname));
}
else {
lastname = g_strdup(c->name);
g_hash_table_replace(contact->data,
g_strdup("last-name"), convert_2_utf8(lastname));
}
g_free(firstname);
g_free(lastname);
}
if (c->cn) {
g_hash_table_replace(contact->data,
g_strdup("cn"), convert_2_utf8(c->cn));
}
if (c->picture) {
gdk_pixbuf_save_to_buffer(
c->picture, &image, &size, "png", NULL, NULL);
g_hash_table_replace(contact->data,
g_strdup("image"), g_base64_encode((const guchar *) image, size));
}
email = g_value_array_new(0);
/* Alias is not available but needed so make an empty string */
g_value_init(&email_member, G_TYPE_STRING);
g_value_set_string(&email_member, "");
g_value_array_append(email, &email_member);
g_value_unset(&email_member);
if (c->email)
str = convert_2_utf8(c->email);
else
str = g_strdup("");
g_value_init(&email_member, G_TYPE_STRING);
g_value_set_string(&email_member, str);
g_value_array_append(email, &email_member);
g_value_unset(&email_member);
g_free(str);
if (c->remarks)
str = convert_2_utf8(c->remarks);
else
str = g_strdup("");
g_value_init(&email_member, G_TYPE_STRING);
g_value_set_string(&email_member, str);
g_value_array_append(email, &email_member);
g_value_unset(&email_member);
g_free(str);
g_ptr_array_add(contact->emails, email);
}
static DBusHandlerResult contact_add_signal(DBusConnection* bus,
DBusMessage* message,
gpointer data) {
DBusError error;
gchar *s = NULL;
if (! compose_instance) {
g_message("Missing compose instance\n");
return DBUS_HANDLER_RESULT_HANDLED;
}
dbus_error_init (&error);
if (dbus_message_is_signal(message, "org.clawsmail.Contacts", "ContactMailTo")) {
if (dbus_message_get_args(
message, &error, DBUS_TYPE_STRING, &s, DBUS_TYPE_INVALID)) {
debug_print("ContactMailTo address received: %s\n", s);
compose_entry_append(compose_instance, s, COMPOSE_TO, PREF_NONE);
}
else {
debug_print("ContactMailTo received with error: %s\n", error.message);
dbus_error_free(&error);
}
}
else if (dbus_message_is_signal(message, "org.clawsmail.Contacts", "ContactMailCc")) {
if (dbus_message_get_args(
message, &error, DBUS_TYPE_STRING, &s, DBUS_TYPE_INVALID)) {
debug_print("ContactMailTo address received: %s\n", s);
compose_entry_append(compose_instance, s, COMPOSE_CC, PREF_NONE);
}
else {
debug_print("ContactMailTo received with error: %s\n", error.message);
dbus_error_free(&error);
}
}
else if (dbus_message_is_signal(message, "org.clawsmail.Contacts", "ContactMailBcc")) {
if (dbus_message_get_args(
message, &error, DBUS_TYPE_STRING, &s, DBUS_TYPE_INVALID)) {
debug_print("ContactMailTo address received: %s\n", s);
compose_entry_append(compose_instance, s, COMPOSE_BCC, PREF_NONE);
}
else {
debug_print("ContactMailTo received with error: %s\n", error.message);
dbus_error_free(&error);
}
}
else {
if (error.message) {
g_warning("Reception error: %s", error.message);
dbus_error_free(&error);
}
debug_print("Unhandled signal received\n");
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
gboolean addressbook_start_service(GError** error) {
gchar* reply = NULL;
gboolean result = FALSE;
if (! init(error))
return result;
if (!org_clawsmail_Contacts_ping(proxy, &reply, error)) {
if (! *error)
g_set_error(error, client_object_error_quark(), 1, "Woops remote method failed");
g_warning ("Woops remote method failed: %s", (*error)->message);
}
if (reply && strcmp("PONG", reply) == 0)
result = TRUE;
return result;
}
int addressbook_dbus_add_contact(ContactData* contact, GError** error) {
DBusContact dbus_contact;
if (! init(error))
return -1;
format_contact(&dbus_contact, contact);
if (!org_clawsmail_Contacts_add_contact(
proxy, contact->book, dbus_contact.data, dbus_contact.emails, error)) {
if (! *error)
g_set_error(error, client_object_error_quark(), 1, "Woops remote method failed");
g_warning ("Woops remote method failed: %s", (*error)->message);
dbus_contact_free(&dbus_contact);
return -1;
}
dbus_contact_free(&dbus_contact);
return 0;
}
gboolean addrindex_dbus_load_completion(gint (*callBackFunc)
(const gchar* name,
const gchar* address,
const gchar* nick,
const gchar* alias,
GList* grp_emails),
GError** error) {
gchar **list = NULL, **contacts;
gchar *name, *email;
if (! init(error))
return FALSE;
if (!org_clawsmail_Contacts_search_addressbook(
proxy, "*", NULL, &list, error)) {
if (! *error)
g_set_error(error, client_object_error_quark(), 1, "Woops remote method failed");
g_warning ("Woops remote method failed: %s", (*error)->message);
g_strfreev(list);
return FALSE;
}
for (contacts = list; *contacts != NULL; contacts += 1) {
gchar* tmp = g_strdup(*contacts);
gchar* pos = g_strrstr(tmp, "\"");
if (pos) {
/* Contact has a name as part of email address */
*pos = '\0';
name = tmp;
name += 1;
pos += 3;
email = pos;
pos = g_strrstr(email, ">");
if (pos)
*pos = '\0';
}
else {
name = "";
email = tmp;
}
debug_print("Adding: %s <%s> to completition\n", name, email);
callBackFunc(name, email, NULL, NULL, NULL);
g_free(tmp);
}
return TRUE;
}
void addressbook_dbus_open(gboolean compose, GError** error) {
if (! init(error))
return;
if (!org_clawsmail_Contacts_show_addressbook(proxy, compose, error)) {
if (! *error)
g_set_error(error, client_object_error_quark(), 1, "Woops remote method failed");
g_warning ("Woops remote method failed: %s", (*error)->message);
}
}
GSList* addressbook_dbus_get_books(GError** error) {
gchar **book_names = NULL, **cur;
GSList* books = NULL;
if (! init(error)) {
return books;
}
if (!org_clawsmail_Contacts_book_list(proxy, &book_names, error)) {
if (! *error)
g_set_error(error, client_object_error_quark(), 1, "Woops remote method failed");
g_warning ("Woops remote method failed: %s", (*error)->message);
g_strfreev(book_names);
return books;
}
for (cur = book_names; *cur; cur += 1)
books = g_slist_prepend(books, g_strdup(*cur));
g_strfreev(book_names);
return books;
}
void contact_data_free(ContactData** data) {
ContactData* contact;
if (! data && ! *data)
return;
contact = *data;
g_free(contact->cn);
g_free(contact->email);
g_free(contact->remarks);
g_free(contact->name);
g_free(contact->book);
g_free(contact);
contact = NULL;
}
void addressbook_harvest(FolderItem *folderItem,
gboolean sourceInd,
GList *msgList ) {
addrgather_dlg_execute(folderItem, sourceInd, msgList);
}
void addressbook_connect_signals(Compose* compose) {
DBusConnection* bus;
DBusError* error = NULL;
g_return_if_fail(compose != NULL);
bus = dbus_bus_get (DBUS_BUS_SESSION, error);
if (!bus) {
g_warning ("Failed to connect to the D-BUS daemon: %s", error->message);
dbus_error_free(error);
return;
}
debug_print("Compose: %p\n", compose);
compose_instance = compose;
dbus_bus_add_match(bus, "type='signal',interface='org.clawsmail.Contacts'", error);
if (error) {
debug_print("Failed to add match to the D-BUS daemon: %s", error->message);
dbus_error_free(error);
return;
}
dbus_connection_add_filter(bus, contact_add_signal, NULL, NULL);
}
gchar* addressbook_get_vcard(const gchar* account, GError** error) {
gchar* vcard = NULL;
g_return_val_if_fail(account != NULL, vcard);
if (! init(error)) {
return vcard;
}
if (!org_clawsmail_Contacts_get_vcard(proxy, account, &vcard, error)) {
if (! *error)
g_set_error(error, client_object_error_quark(), 1, "Woops remote method failed");
g_warning ("Woops remote method failed: %s", (*error)->message);
g_free(vcard);
vcard = NULL;
}
return vcard;
}
gboolean addressbook_add_vcard(const gchar* abook, const gchar* vcard, GError** error) {
gboolean result = FALSE;
return result;
}
static gboolean my_compose_create_hook(gpointer source, gpointer user_data) {
Compose *compose = (Compose*) source;
GError* error = NULL;
gchar* vcard = addressbook_get_vcard("test", &error);
if (error) {
g_warning("%s", error->message);
g_clear_error(&error);
}
else {
debug_print("test.vcf:\n%s\n", vcard);
g_free(vcard);
}
return FALSE;
}
void addressbook_install_hooks(GError** error) {
if ((guint)-1 == hooks_register_hook(
COMPOSE_CREATED_HOOKLIST, my_compose_create_hook, NULL)) {
g_warning("Could not register hook for adding vCards\n");
if (error) {
g_set_error(error, client_object_error_quark(), 1,
"Could not register hook for adding vCards");
}
}
}

75
src/addressbook-dbus.h Normal file
View file

@ -0,0 +1,75 @@
/*
* $Id$
*/
/* vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: */
/*
* Claws-contacts is a proposed new design for the address book feature
* in Claws Mail. The goal for this new design was to create a
* solution more suitable for the term lightweight and to be more
* maintainable than the present implementation.
*
* More lightweight is achieved by design, in that sence that the whole
* structure is based on a plugable design.
*
* Claws Mail is Copyright (C) 1999-2011 by the Claws Mail Team and
* Claws-contacts is Copyright (C) 2011 by Michael Rasmussen.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __ADDRESSBOOK_DBUS_H__
#define __ADDRESSBOOK_DBUS_H__
#include <glib.h>
G_BEGIN_DECLS
#include <gtk/gtk.h>
#include "folder.h"
#include "compose.h"
typedef struct {
gchar* cn;
gchar* email;
gchar* remarks;
gchar* name;
gchar* book;
GdkPixbuf* picture;
} ContactData;
gboolean addressbook_start_service(GError** error);
void addressbook_install_hooks(GError** error);
int addressbook_dbus_add_contact(ContactData* contact, GError** error);
gboolean addrindex_dbus_load_completion(gint (*callBackFunc)
(const gchar* name,
const gchar* address,
const gchar* nick,
const gchar* alias,
GList* grp_emails),
GError** error);
void addressbook_dbus_open(gboolean compose, GError** error);
GSList* addressbook_dbus_get_books(GError** error);
void contact_data_free(ContactData** data);
void addressbook_harvest(FolderItem *folderItem,
gboolean sourceInd,
GList *msgList );
void addressbook_connect_signals(Compose* compose);
gchar* addressbook_get_vcard(const gchar* account, GError** error);
gboolean addressbook_add_vcard(const gchar* abook, const gchar* vcard, GError** error);
G_END_DECLS
#endif

View file

@ -45,9 +45,12 @@
#include "prefs_common.h"
#include "addrharvest.h"
#include "addrindex.h"
#include "addrbook.h"
#ifndef USE_NEW_ADDRBOOK
#include "addrindex.h"
#include "addrbook.h"
#else
#include "addressbook-dbus.h"
#endif
#define PAGE_FIELDS 0
#define PAGE_FINISH 1
@ -74,7 +77,9 @@ static struct _AddrHarvest {
GtkWidget *labelFolder;
GtkWidget *entryBook;
GtkWidget *checkHeader[ NUM_FIELDS ];
#ifndef USE_NEW_ADDRBOOK
GtkWidget *spinbtnFolder;
#endif
GtkWidget *checkRecurse;
GtkWidget *btnOk;
GtkWidget *btnCancel;
@ -86,8 +91,10 @@ static struct _AddrHarvest {
GtkWidget *clistCount;
} addrgather_dlg;
#ifndef USE_NEW_ADDRBOOK
static AddressIndex *_harv_addressIndex_;
static AddressBookFile *_harv_addressBook_;
#endif
static gchar *_harv_headerNames_[] = {
HEADER_FROM,
HEADER_REPLY_TO,
@ -143,12 +150,19 @@ static gboolean addrgather_dlg_harvest() {
GtkCMCList *clist;
gchar *text[ FIELDS_N_COLS ];
AddressHarvester *harvester;
AddressBookFile *abf;
gchar *name;
#ifndef USE_NEW_ADDRBOOK
AddressBookFile *abf;
gchar *newFile;
#else
GList* list;
ContactData* contact;
GError* error = NULL;
#endif
gchar str[ FMT_BUFSIZE ];
gint cnt;
gint i;
#ifndef USE_NEW_ADDRBOOK
gint sz;
name = gtk_editable_get_chars( GTK_EDITABLE(addrgather_dlg.entryBook), 0, -1 );
@ -157,6 +171,14 @@ static gboolean addrgather_dlg_harvest() {
_( "Please specify name for address book." ) );
g_free( name );
return FALSE;
#else
name = gtk_combo_box_get_active_text(GTK_COMBO_BOX(addrgather_dlg.entryBook));
if( name == NULL || strlen( name ) < 1 ) {
addrgather_dlg_status_show(
_("No available address book."));
g_free( name );
return FALSE;
#endif
}
/* Create harvest helper */
@ -183,10 +205,13 @@ static gboolean addrgather_dlg_harvest() {
/* Go fer it */
addrgather_dlg_status_show( _( "Collecting addresses..." ) );
GTK_EVENTS_FLUSH();
#ifndef USE_NEW_ADDRBOOK
sz = gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON( addrgather_dlg.spinbtnFolder ) );
addrharvest_set_folder_size( harvester, sz );
#endif
#ifndef USE_NEW_ADDRBOOK
/* Create address book */
abf = addrbook_create_book();
addrbook_set_path( abf, _harv_addressIndex_->filePath );
@ -195,12 +220,38 @@ static gboolean addrgather_dlg_harvest() {
addrbook_set_name( abf, name );
g_free( newFile );
g_free( name );
#endif
/* Harvest addresses */
#ifndef USE_NEW_ADDRBOOK
addrharvest_harvest(
harvester, abf->addressCache, _harv_messageList_ );
/* save address book */
addrbook_save_data( abf );
_harv_addressBook_ = abf;
#else
addrharvest_harvest(
harvester, NULL, _harv_messageList_ );
list = g_hash_table_get_values(harvester->dupTable);
for (; list; list = g_list_next(list)) {
contact = g_new0(ContactData, 1);
ContactEntry* person = (ContactEntry *) list->data;
if (person->first_name)
contact->name = g_strconcat(
person->first_name, " ", person->last_name, NULL);
else
contact->name = g_strdup(person->last_name);
if (! contact->name || strlen(contact->name) < 1)
contact->name = g_strdup(person->email);
contact->remarks = g_strdup(N_("address added by claws-mail"));
contact->email = g_strdup(person->email);
contact->book = g_strdup(name);
addressbook_dbus_add_contact(contact, &error);
contact_data_free(&contact);
}
g_list_free(list);
g_free(name);
#endif
/* Update summary count */
clist = GTK_CMCLIST(addrgather_dlg.clistCount);
@ -263,18 +314,24 @@ static void addrgather_page_fields(gint pageNum, gchar *pageLbl)
{
GtkWidget *vbox;
GtkWidget *vboxf;
GtkWidget *hboxs;
GtkWidget *table;
GtkWidget *label;
GtkWidget *labelFolder;
GtkWidget *entryBook;
GtkWidget *frameHeader;
GtkWidget *checkHeader[NUM_FIELDS];
#ifndef USE_NEW_ADDRBOOK
GtkWidget *hboxs;
GtkWidget *spinbtnFolder;
GtkAdjustment *adjFolder;
GtkObject *adjFolder;
#endif
GtkWidget *checkRecurse;
gint top;
gint i;
#ifdef USE_NEW_ADDRBOOK
GError* error = NULL;
GSList *books, *cur;
#endif
/* Container */
vbox = gtk_vbox_new(FALSE, 6);
@ -311,10 +368,27 @@ static void addrgather_page_fields(gint pageNum, gchar *pageLbl)
gtk_table_attach( GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0 );
gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
#ifndef USE_NEW_ADDRBOOK
entryBook = gtk_entry_new();
#else
books = addressbook_dbus_get_books(&error);
entryBook = gtk_combo_box_new_text();
if (books) {
for (cur = books; cur; cur = g_slist_next(cur)) {
gchar* book = (gchar *) cur->data;
gtk_combo_box_prepend_text(GTK_COMBO_BOX(entryBook), book);
g_free(book);
}
g_slist_free(books);
}
else
gtk_combo_box_prepend_text(GTK_COMBO_BOX(entryBook), "");
gtk_combo_box_set_active(GTK_COMBO_BOX(entryBook), 0);
#endif
gtk_table_attach( GTK_TABLE(table), entryBook, 1, 2, top, (top + 1),
GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0 );
#ifndef USE_NEW_ADDRBOOK
/* Third row */
top = 2;
label = gtk_label_new(_("Address book folder size:"));
@ -332,7 +406,7 @@ static void addrgather_page_fields(gint pageNum, gchar *pageLbl)
gtk_table_attach(GTK_TABLE(table), hboxs, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0);
CLAWS_SET_TIP(spinbtnFolder,
_("Maximum amount of entries per folder within the newly created address book"));
#endif
/* Fourth row */
top = 3;
frameHeader = gtk_frame_new(_("Process these mail header fields"));
@ -360,7 +434,9 @@ static void addrgather_page_fields(gint pageNum, gchar *pageLbl)
addrgather_dlg.labelFolder = labelFolder;
addrgather_dlg.entryBook = entryBook;
#ifndef USE_NEW_ADDRBOOK
addrgather_dlg.spinbtnFolder = spinbtnFolder;
#endif
addrgather_dlg.checkRecurse = checkRecurse;
}
@ -376,7 +452,6 @@ static void addrgather_page_finish( gint pageNum, gchar *pageLbl ) {
GtkWidget *clistCount;
gchar *titles[ FIELDS_N_COLS ];
gint i;
titles[ FIELD_COL_HEADER ] = _("Header Name");
titles[ FIELD_COL_COUNT ] = _("Address Count");
@ -501,13 +576,19 @@ static void addrgather_dlg_create(void)
* msgList List of message numbers, or NULL to process folder.
* Return: Populated address book file, or NULL if none created.
*/
#ifndef USE_NEW_ADDRBOOK
AddressBookFile *addrgather_dlg_execute(FolderItem *folderItem, AddressIndex *addrIndex,
gboolean sourceInd, GList *msgList)
#else
void addrgather_dlg_execute(FolderItem *folderItem, gboolean sourceInd, GList *msgList)
#endif
{
gint i;
#ifndef USE_NEW_ADDRBOOK
_harv_addressIndex_ = addrIndex;
_harv_addressBook_ = NULL;
#endif
_harv_messageList_ = msgList;
/* Create dialog */
@ -520,8 +601,11 @@ AddressBookFile *addrgather_dlg_execute(FolderItem *folderItem, AddressIndex *ad
addrgather_dlg.folderPath = folder_item_get_path(folderItem);
/* Setup some default values */
gtk_label_set_text(GTK_LABEL(addrgather_dlg.labelFolder), folderItem->path);
#ifndef USE_NEW_ADDRBOOK
gtk_entry_set_text(GTK_ENTRY(addrgather_dlg.entryBook), folderItem->path);
#endif
for (i = 0; i < NUM_FIELDS; i++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(addrgather_dlg.checkHeader[i]),
@ -558,14 +642,15 @@ AddressBookFile *addrgather_dlg_execute(FolderItem *folderItem, AddressIndex *ad
addrgather_dlg.folderPath = NULL;
gtk_widget_hide(addrgather_dlg.window);
gtk_window_set_modal(GTK_WINDOW(addrgather_dlg.window), FALSE);
#ifndef USE_NEW_ADDRBOOK
_harv_addressIndex_ = NULL;
if (addrgather_dlg.cancelled == TRUE)
return NULL;
return _harv_addressBook_;
#endif
}
/*
* End of Source.
*/

View file

@ -25,11 +25,20 @@
#define __ADDR_GATHER_H__
/* Function prototypes */
#include "folder.h"
#ifndef USE_NEW_ADDRBOOK
#include "addrbook.h"
AddressBookFile *addrgather_dlg_execute( FolderItem *folderItem,
AddressIndex *addrIndex,
gboolean sourceInd,
GList *msgList );
#else
void addrgather_dlg_execute( FolderItem *folderItem,
gboolean sourceInd,
GList *msgList );
#endif
#endif /* __ADDR_GATHER_H__ */
/*

View file

@ -31,6 +31,9 @@
#include "addrharvest.h"
#include "codeconv.h"
#include "addritem.h"
#ifdef USE_NEW_ADDRBOOK
#include "addressbook-dbus.h"
#endif
/* Mail header names of interest */
static gchar *_headerFrom_ = HEADER_FROM;
@ -63,6 +66,14 @@ struct _HeaderEntry {
gint count;
};
#ifdef USE_NEW_ADDRBOOK
typedef enum {
FIRST = 0,
LAST,
} Namepart;
#endif
/*
* Build header table entry.
* Enter: harvester Harvester object.
@ -269,6 +280,32 @@ void addrharvest_free( AddressHarvester *harvester ) {
g_free( harvester );
}
#ifdef USE_NEW_ADDRBOOK
static gchar* get_namepart(const gchar* name, Namepart namepart) {
gchar *pos, *part = NULL;
gchar *token = g_strdup(name);
pos = g_strrstr(token, " ");
if (namepart == FIRST) {
if (pos) {
*pos = '\0';
part = g_strdup(token);
*pos = ' ';
}
}
else {
if (! pos)
part = g_strdup(token);
else {
pos +=1;
part = g_strdup(pos);
}
}
g_free(token);
return part;
}
#endif
/*
* Insert address into cache.
* Enter: harvester Harvester object.
@ -282,6 +319,7 @@ static void addrharvest_insert_cache(
AddressCache *cache, const gchar *name,
const gchar *address )
{
#ifndef USE_NEW_ADDRBOOK
ItemPerson *person;
ItemFolder *folder;
gchar *folderName;
@ -297,10 +335,15 @@ static void addrharvest_insert_cache(
if( entry->count % harvester->folderSize == 0 ) {
newFolder = TRUE; /* Folder is full */
}
#else
ContactEntry* person;
gchar* key;
#endif
/* Insert address */
key = g_utf8_strdown( address, -1 );
person = g_hash_table_lookup( harvester->dupTable, key );
#ifndef USE_NEW_ADDRBOOK
if( person ) {
/* Update existing person to use longest name */
value = ADDRITEM_NAME(person);
@ -331,6 +374,16 @@ static void addrharvest_insert_cache(
entry->count++;
}
addritem_parse_first_last( person );
#else
if (! person) {
person = g_new0(ContactEntry, 1);
person->first_name = get_namepart(name, FIRST);
person->last_name = get_namepart(name, LAST);
person->email = g_strdup(address);
g_hash_table_insert(harvester->dupTable, key, person);
entry->count++;
}
#endif
}
/*
@ -533,8 +586,13 @@ static void addrharvest_parse_address(
}
/* Insert into address book */
#ifndef USE_NEW_ADDRBOOK
addrharvest_insert_cache(
harvester, entry, cache, name, email );
#else
addrharvest_insert_cache(
harvester, entry, NULL, name, email);
#endif
g_free( email );
g_free( name );
}
@ -791,13 +849,16 @@ gint addrharvest_harvest(
retVal = MGU_BAD_ARGS;
cm_return_val_if_fail( harvester != NULL, retVal );
#ifndef USE_NEW_ADDRBOOK
cm_return_val_if_fail( cache != NULL, retVal );
#endif
cm_return_val_if_fail( harvester->path != NULL, retVal );
#ifndef USE_NEW_ADDRBOOK
/* Clear cache */
addrcache_clear( cache );
cache->dataRead = FALSE;
#endif
/* Build list of headers of interest */
listHdr = NULL;
node = harvester->headerTable;
@ -823,10 +884,11 @@ gint addrharvest_harvest(
}
mgu_free_dlist( listHdr );
#ifndef USE_NEW_ADDRBOOK
/* Mark cache */
cache->modified = FALSE;
cache->dataRead = TRUE;
#endif
return retVal;
}

View file

@ -47,6 +47,14 @@ struct _AddressHarvester {
gboolean folderRecurse;
};
#ifdef USE_NEW_ADDRBOOK
typedef struct {
gchar* first_name;
gchar* last_name;
gchar* email;
} ContactEntry;
#endif
/* Function prototypes */
AddressHarvester *addrharvest_create ( void );
void addrharvest_free ( AddressHarvester *harvester );

68
src/claws-contacts.xml Normal file
View file

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
"http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
<!--
# $Id$
-->
<node name="/org/clawsmail/contacts/service">
<interface name="org.clawsmail.Contacts">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="abook"/>
<method name="ShowAddressbook">
<arg type="b" name="compose" direction="in" />
</method>
<method name="Ping">
<arg type="s" name="reply" direction="out" />
</method>
<method name="Commit">
<arg type="s" name="addressbook" direction="in" />
<arg type="b" name="succes" direction="out" />
</method>
<method name="BookList">
<arg type="as" name="books" direction="out" />
</method>
<method name="SearchAddressbook">
<arg type="s" name="token" direction="in" />
<!-- if addressbook is NULL search all available books -->
<arg type="s" name="addressbook" direction="in" />
<arg type="as" name="emails" direction="out" />
</method>
<method name="AddContact">
<arg type="s" name="addressbook" direction="in" />
<arg type="a{ss}" name="contact_data" direction="in" />
<arg type="a(sss)" name="contact_emails" direction="in" />
</method>
<method name="AddVCard">
<!-- if addressbook is NULL add to default address book -->
<arg type="s" name="addressbook" direction="in" />
<arg type="s" name="vcard" direction="in" />
</method>
<method name="GetVCard">
<arg type="s" name="acount" direction="in" />
<arg type="s" name="vcard" direction="out" />
</method>
<signal name="ContactMailTo">
<arg type="s" name="contact_add_to" direction="out" />
</signal>
<signal name="ContactMailCc">
<arg type="s" name="contact_add_cc" direction="out" />
</signal>
<signal name="ContactMailBcc">
<arg type="s" name="contact_add_bcc" direction="out" />
</signal>
</interface>
</node>

View file

@ -60,7 +60,12 @@
#include "main.h"
#include "mainwindow.h"
#include "compose.h"
#include "addressbook.h"
#ifndef USE_NEW_ADDRBOOK
#include "addressbook.h"
#else
#include "addressbook-dbus.h"
#include "addressadd.h"
#endif
#include "folderview.h"
#include "procmsg.h"
#include "menu.h"
@ -5010,7 +5015,7 @@ gint compose_send(Compose *compose)
compose_allow_user_actions (compose, FALSE);
compose->sending = TRUE;
if (compose_check_entries(compose, TRUE) == FALSE) {
if ((compose, TRUE) == FALSE) {
if (compose->batch) {
gtk_widget_show_all(compose->window);
}
@ -6571,7 +6576,14 @@ static void compose_add_to_addressbook_cb(GtkMenuItem *menuitem, gpointer user_d
if (*address != '\0') {
gchar *name = procheader_get_fromname(address);
extract_address(address);
#ifndef USE_NEW_ADDRBOOK
addressbook_add_contact(name, address, NULL, NULL);
#else
debug_print("%s: %s\n", name, address);
if (addressadd_selection(name, address, NULL, NULL)) {
debug_print( "addressbook_add_contact - added\n" );
}
#endif
}
g_free(address);
}
@ -7796,8 +7808,9 @@ static Compose *compose_create(PrefsAccount *account,
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((compose->header_last->combo)))),
prefs_common_translated_header_name("Newsgroups:"));
#ifndef USE_NEW_ADDRBOOK
addressbook_set_target_compose(compose);
#endif
if (mode != COMPOSE_REDIRECT)
compose_set_template_menu(compose);
else {
@ -8528,9 +8541,10 @@ static void compose_destroy(Compose *compose)
g_free(compose->privacy_system);
#ifndef USE_NEW_ADDRBOOK
if (addressbook_get_target_compose() == compose)
addressbook_set_target_compose(NULL);
#endif
#if USE_ENCHANT
if (compose->gtkaspell) {
gtkaspell_delete(compose->gtkaspell);
@ -9979,7 +9993,17 @@ static void compose_address_cb(GtkAction *action, gpointer data)
{
Compose *compose = (Compose *)data;
#ifndef USE_NEW_ADDRBOOK
addressbook_open(compose);
#else
GError* error = NULL;
addressbook_connect_signals(compose);
addressbook_dbus_open(TRUE, &error);
if (error) {
g_warning("%s", error->message);
g_error_free(error);
}
#endif
}
static void about_show_cb(GtkAction *action, gpointer data)

View file

@ -28,7 +28,9 @@ typedef struct _AttachInfo AttachInfo;
#include "procmsg.h"
#include "procmime.h"
#ifndef USE_NEW_ADDRBOOK
#include "addressbook.h"
#endif
#include "prefs_account.h"
#include "undo.h"
#include "toolbar.h"

View file

@ -34,7 +34,13 @@
#include "prefs_gtk.h"
#include "compose.h"
#include "prefs_common.h"
#include "addrbook.h"
#include "addritem.h"
#ifndef USE_NEW_ADDRBOOK
#include "addrbook.h"
#else
#include "addressbook-dbus.h"
#include "addressadd.h"
#endif
#include "addr_compl.h"
#include "tags.h"
#include "log.h"
@ -476,13 +482,16 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
case MATCHACTION_ADD_TO_ADDRESSBOOK:
{
#ifndef USE_NEW_ADDRBOOK
AddressDataSource *book = NULL;
AddressBookFile *abf = NULL;
ItemFolder *folder = NULL;
#endif
gchar buf[BUFFSIZE];
Header *header;
gint errors = 0;
#ifndef USE_NEW_ADDRBOOK
if (!addressbook_peek_folder_exists(action->destination, &book, &folder)) {
g_warning("addressbook folder not found '%s'\n", action->destination?action->destination:"(null)");
return FALSE;
@ -493,7 +502,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
}
abf = book->rawDataSource;
#endif
/* get the header */
procheader_get_header_from_msginfo(info, buf, sizeof(buf), action->header);
header = procheader_parse_header(buf);
@ -520,7 +529,11 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
if (complete_matches_found(walk->data) == 0) {
debug_print("adding address '%s' to addressbook '%s'\n",
stripped_addr, action->destination);
#ifndef USE_NEW_ADDRBOOK
if (!addrbook_add_contact(abf, folder, stripped_addr, stripped_addr, NULL)) {
#else
if (!addressadd_selection(NULL, stripped_addr, NULL, NULL)) {
#endif
g_warning("contact could not been added\n");
errors++;
}
@ -538,7 +551,6 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
}
return (errors == 0);
}
default:
break;
}

View file

@ -327,6 +327,7 @@ static gint headerview_show_face (HeaderView *headerview, MsgInfo *msginfo)
static void headerview_save_contact_pic (HeaderView *headerview, MsgInfo *msginfo)
{
#ifndef USE_NEW_ADDRBOOK
gchar *filename = NULL;
GError *error = NULL;
GdkPixbuf *picture = NULL;
@ -349,10 +350,14 @@ static void headerview_save_contact_pic (HeaderView *headerview, MsgInfo *msginf
}
}
g_free(filename);
#else
/* new address book */
#endif
}
static gint headerview_show_contact_pic (HeaderView *headerview, MsgInfo *msginfo)
{
#ifndef USE_NEW_ADDRBOOK
GtkWidget *hbox = headerview->hbox;
GtkWidget *image;
gchar *filename = NULL;
@ -406,6 +411,10 @@ static gint headerview_show_contact_pic (HeaderView *headerview, MsgInfo *msginf
return -1;
else
return 0;
#else
/* new address book */
return -1;
#endif
}
void headerview_clear(HeaderView *headerview)

View file

@ -93,7 +93,11 @@
#include "manage_window.h"
#include "alertpanel.h"
#include "statusbar.h"
#include "addressbook.h"
#ifndef USE_NEW_ADDRBOOK
#include "addressbook.h"
#else
#include "addressbook-dbus.h"
#endif
#include "compose.h"
#include "folder.h"
#include "setup.h"
@ -1315,8 +1319,18 @@ int main(int argc, char *argv[])
prefs_actions_read_config();
prefs_display_header_read_config();
/* prefs_filtering_read_config(); */
#ifndef USE_NEW_ADDRBOOK
addressbook_read_file();
#else
g_clear_error(&error);
if (! addressbook_start_service(&error)) {
g_warning("%s", error->message);
g_clear_error(&error);
}
else {
addressbook_install_hooks(&error);
}
#endif
gtkut_widget_init();
stock_pixbuf_gdk(NULL, STOCK_PIXMAP_CLAWS_MAIL_ICON, &icon);
gtk_window_set_default_icon(icon);
@ -1719,8 +1733,9 @@ static void exit_claws(MainWindow *mainwin)
prefs_common_write_config();
account_write_config_all();
#ifndef USE_NEW_ADDRBOOK
addressbook_export_to_file();
#endif
filename = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
gtk_accel_map_save(filename);
g_free(filename);
@ -1759,8 +1774,9 @@ static void exit_claws(MainWindow *mainwin)
prefs_toolbar_done();
#ifndef USE_NEW_ADDRBOOK
addressbook_destroy();
#endif
prefs_themes_done();
prefs_fonts_done();
prefs_ext_prog_done();

View file

@ -52,7 +52,11 @@
#include "prefs_template.h"
#include "action.h"
#include "account.h"
#include "addressbook.h"
#ifndef USE_NEW_ADDRBOOK
#include "addressbook.h"
#else
#include "addressbook-dbus.h"
#endif
#include "logwindow.h"
#include "manage_window.h"
#include "alertpanel.h"
@ -2432,7 +2436,9 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
folderview_reinit_fonts(mainwin->folderview);
summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
foldersel_reflect_prefs_pixmap_theme();
#ifndef USE_NEW_ADDRBOOK
addressbook_reflect_prefs_pixmap_theme();
#endif
#ifndef GENERIC_UMPC
pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
@ -4315,7 +4321,18 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
static void addressbook_open_cb(GtkAction *action, gpointer data)
{
#ifndef USE_NEW_ADDRBOOK
addressbook_open(NULL);
#else
GError* error = NULL;
addressbook_dbus_open(FALSE, &error);
if (error) {
g_warning("Failed to open address book");
g_warning("%s", error->message);
g_error_free(error);
}
#endif
}
static void log_window_show_cb(GtkAction *action, gpointer data)
@ -5235,6 +5252,7 @@ gboolean mainwindow_is_obscured(void)
static void addr_harvest_cb( GtkAction *action, gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
}

View file

@ -39,7 +39,6 @@
#include "filesel.h"
#include "foldersel.h"
#include "sourcewindow.h"
#include "addressbook.h"
#include "alertpanel.h"
#include "inputdialog.h"
#include "mainwindow.h"
@ -66,7 +65,12 @@
#include "quoted-printable.h"
#include "version.h"
#include "statusbar.h"
#ifndef USE_NEW_ADDRBOOK
#include "addressbook.h"
#else
#include "addressadd.h"
#include "addressbook-dbus.h"
#endif
static GList *messageview_list = NULL;
static gint messageview_delete_cb (GtkWidget *widget,
@ -2779,7 +2783,18 @@ static void reply_cb(GtkAction *gaction, gpointer data)
static void addressbook_open_cb(GtkAction *action, gpointer data)
{
#ifndef USE_NEW_ADDRBOOK
addressbook_open(NULL);
#else
GError* error = NULL;
addressbook_dbus_open(FALSE, &error);
if (error) {
g_warning("Failed to open address book");
g_warning("%s", error->message);
g_error_free(error);
}
#endif
}
static void add_address_cb(GtkAction *action, gpointer data)
@ -2817,8 +2832,13 @@ static void add_address_cb(GtkAction *action, gpointer data)
if (image)
picture = gtk_image_get_pixbuf(GTK_IMAGE(image));
#ifndef USE_NEW_ADDRBOOK
addressbook_add_contact(msginfo->fromname, from, NULL, picture);
#else
if (addressadd_selection(msginfo->fromname, from, NULL, picture)) {
debug_print( "addressbook_add_contact - added\n" );
}
#endif
if (image)
gtk_widget_destroy(image);
}

View file

@ -78,6 +78,7 @@ static void foldersel_cb(GtkWidget *widget, gpointer data)
}
}
#ifndef USE_NEW_ADDRBOOK
static void bogofilter_whitelist_ab_select_cb(GtkWidget *widget, gpointer data)
{
struct BogofilterPage *page = (struct BogofilterPage *) data;
@ -91,6 +92,7 @@ static void bogofilter_whitelist_ab_select_cb(GtkWidget *widget, gpointer data)
g_free(new_path);
}
}
#endif
static void bogofilter_create_widget_func(PrefsPage * _page,
GtkWindow * window,
@ -268,7 +270,9 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
SET_TOGGLE_SENSITIVITY(save_unsure_checkbtn, save_unsure_folder_entry);
SET_TOGGLE_SENSITIVITY(save_unsure_checkbtn, save_unsure_folder_select);
SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, whitelist_ab_folder_combo);
#ifndef USE_NEW_ADDRBOOK
SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, whitelist_ab_select_btn);
#endif
SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, learn_from_whitelist_chkbtn);
SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, mark_as_read_checkbtn);
@ -278,9 +282,12 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
G_CALLBACK(foldersel_cb), save_spam_folder_entry);
g_signal_connect(G_OBJECT(save_unsure_folder_select), "clicked",
G_CALLBACK(foldersel_cb), save_unsure_folder_entry);
#ifndef USE_NEW_ADDRBOOK
g_signal_connect(G_OBJECT (whitelist_ab_select_btn), "clicked",
G_CALLBACK(bogofilter_whitelist_ab_select_cb), page);
#else
gtk_widget_set_sensitive(GTK_WIDGET(whitelist_ab_select_btn), FALSE);
#endif
gtk_spin_button_set_value(GTK_SPIN_BUTTON(max_size_spinbtn), (float) config->max_size);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(process_emails_checkbtn), config->process_emails);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_spam_checkbtn), config->receive_spam);

View file

@ -77,6 +77,7 @@ static void create_dillo_prefs_page (PrefsPage *page,
static void destroy_dillo_prefs_page (PrefsPage *page);
static void save_dillo_prefs (PrefsPage *page);
#ifndef USE_NEW_ADDRBOOK
static void dillo_whitelist_ab_select_cb(GtkWidget *widget, gpointer data)
{
DilloBrowserPage *page = (DilloBrowserPage *) data;
@ -90,6 +91,7 @@ static void dillo_whitelist_ab_select_cb(GtkWidget *widget, gpointer data)
g_free(new_path);
}
}
#endif
static void local_checkbox_toggled(GtkToggleButton *button,
gpointer user_data)
@ -100,8 +102,10 @@ static void local_checkbox_toggled(GtkToggleButton *button,
gtk_widget_set_sensitive(prefs_page->whitelist_ab, active);
gtk_widget_set_sensitive(prefs_page->whitelist_ab_folder_combo, active &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_page->whitelist_ab)));
#ifndef USE_NEW_ADDRBOOK
gtk_widget_set_sensitive(prefs_page->whitelist_ab_select_btn, active &&
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_page->whitelist_ab)));
#endif
}
static void whitelist_checkbox_toggled(GtkToggleButton *button,
@ -233,9 +237,12 @@ static void create_dillo_prefs_page(PrefsPage *page,
G_CALLBACK(whitelist_checkbox_toggled),
prefs_page);
#ifndef USE_NEW_ADDRBOOK
g_signal_connect(G_OBJECT (whitelist_ab_select_btn), "clicked",
G_CALLBACK(dillo_whitelist_ab_select_cb), prefs_page);
#else
gtk_widget_set_sensitive(GTK_WIDGET(whitelist_ab_select_btn), FALSE);
#endif
gtk_widget_set_sensitive(whitelist_ab_checkbtn, !dillo_prefs.local);
gtk_widget_set_sensitive(whitelist_ab_folder_combo, !dillo_prefs.local && dillo_prefs.whitelist_ab);
gtk_widget_set_sensitive(whitelist_ab_select_btn, !dillo_prefs.local && dillo_prefs.whitelist_ab);

View file

@ -92,6 +92,7 @@ struct Transport transports[] = {
{ N_("Unix Socket"), SPAMASSASSIN_TRANSPORT_UNIX, PAGE_UNIX, 0 },
};
#ifndef USE_NEW_ADDRBOOK
static void spamassassin_whitelist_ab_select_cb(GtkWidget *widget, gpointer data)
{
struct SpamAssassinPage *page = (struct SpamAssassinPage *) data;
@ -105,6 +106,7 @@ static void spamassassin_whitelist_ab_select_cb(GtkWidget *widget, gpointer data
g_free(new_path);
}
}
#endif
static void foldersel_cb(GtkWidget *widget, gpointer data)
{
@ -456,14 +458,19 @@ static void spamassassin_create_widget_func(PrefsPage * _page,
SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, hbox_process_emails);
SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, mark_as_read_checkbtn);
SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, whitelist_ab_folder_combo);
#ifndef USE_NEW_ADDRBOOK
SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, whitelist_ab_select_btn);
#endif
config = spamassassin_get_config();
g_signal_connect(G_OBJECT(save_spam_folder_select), "clicked",
G_CALLBACK(foldersel_cb), page);
#ifndef USE_NEW_ADDRBOOK
g_signal_connect(G_OBJECT (whitelist_ab_select_btn), "clicked",
G_CALLBACK(spamassassin_whitelist_ab_select_cb), page);
#else
gtk_widget_set_sensitive(GTK_WIDGET(whitelist_ab_select_btn), FALSE);
#endif
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enable_sa_checkbtn), config->enable);
if (config->username != NULL)

View file

@ -42,6 +42,9 @@
#include "alertpanel.h"
#include "account.h"
#include "gtk/manage_window.h"
#ifdef USE_NEW_ADDRBOOK
#include "addressbook-dbus.h"
#endif
#include "trayicon_prefs.h"
@ -530,7 +533,16 @@ static void trayicon_compose_acc_cb( GtkMenuItem *menuitem, gpointer data )
static void trayicon_addressbook_cb( GtkAction *action, gpointer data )
{
#ifndef USE_NEW_ADDRBOOK
addressbook_open(NULL);
#else
GError* error = NULL;
addressbook_dbus_open(FALSE, &error);
if (error) {
g_warning("%s", error->message);
g_error_free(error);
}
#endif
}
static void trayicon_toggle_offline_cb( GtkAction *action, gpointer data )

View file

@ -59,7 +59,9 @@
#include "stock_pixmap.h"
#include "prefswindow.h"
#include "colorlabel.h"
#include "addrcustomattr.h"
#ifndef USE_NEW_ADDRBOOK
#include "addrcustomattr.h"
#endif
enum {
DATEFMT_FMT,
@ -1261,9 +1263,9 @@ void prefs_common_read_config(void)
prefs_common_read_history(MESSAGE_SEARCH_HISTORY);
prefs_common.compose_save_to_history =
prefs_common_read_history(COMPOSE_SAVE_TO_HISTORY);
#ifndef USE_NEW_ADDRBOOK
prefs_common.addressbook_custom_attributes = addressbook_update_custom_attr_from_prefs();
#endif
colorlabel_update_colortable_from_prefs();
}
@ -1360,9 +1362,11 @@ void prefs_common_write_config(void)
prefs_common_save_history(COMPOSE_SAVE_TO_HISTORY,
prefs_common.compose_save_to_history);
prefs_common_save_history_to_dir(ADDRBOOK_DIR,
#ifndef USE_NEW_ADDRBOOK
prefs_common_save_history_to_dir(ADDRBOOK_DIR,
ADDRESSBOOK_CUSTOM_ATTRIBUTES,
prefs_common.addressbook_custom_attributes);
#endif
}
/* make a copy of string 'in' into buffer 'out'. un-escape \ sequences.

View file

@ -76,7 +76,9 @@ static gint prefs_filtering_action_deleted(GtkWidget *widget,
static void prefs_filtering_action_type_selection_changed(GtkWidget *widget,
gpointer user_data);
static void prefs_filtering_action_select_dest(void);
#ifndef USE_NEW_ADDRBOOK
static void prefs_filtering_action_select_addressbook(void);
#endif
static void prefs_filtering_action_up(void);
static void prefs_filtering_action_down(void);
static void prefs_filtering_action_set_dialog(GSList *action_list);
@ -550,10 +552,13 @@ static void prefs_filtering_action_create(void)
addressbook_btn = gtk_button_new_with_label (_("Select ..."));
gtk_box_pack_start (GTK_BOX (hbox1), addressbook_btn, FALSE, FALSE, 0);
#ifndef USE_NEW_ADDRBOOK
g_signal_connect (G_OBJECT (addressbook_btn), "clicked",
G_CALLBACK(prefs_filtering_action_select_addressbook),
NULL);
#else
gtk_widget_set_sensitive(GTK_WIDGET(addressbook_btn), FALSE);
#endif
exec_btn = gtk_button_new_from_stock(GTK_STOCK_INFO);
gtk_box_pack_start (GTK_BOX (hbox1), exec_btn, FALSE, FALSE, 0);
g_signal_connect (G_OBJECT (exec_btn), "clicked",
@ -645,7 +650,9 @@ static void prefs_filtering_action_create(void)
filtering_action.score_entry = score_entry;
filtering_action.header_combo = header_combo;
filtering_action.header_entry = header_entry;
#ifndef USE_NEW_ADDRBOOK
filtering_action.addressbook_btn = addressbook_btn;
#endif
filtering_action.ok_btn = ok_btn;
filtering_action.action_list_view = action_list_view;
@ -1263,6 +1270,7 @@ static void prefs_filtering_action_select_dest(void)
g_free(path);
}
#ifndef USE_NEW_ADDRBOOK
static void prefs_filtering_action_select_addressbook(void)
{
const gchar *folderpath = NULL;
@ -1275,6 +1283,7 @@ static void prefs_filtering_action_select_addressbook(void)
g_free(new_path);
}
}
#endif
static void prefs_filtering_action_enable_widget(GtkWidget* widget, const gboolean enable)
{

View file

@ -55,7 +55,9 @@
#include "colorlabel.h"
#include "tags.h"
#ifndef USE_NEW_ADDRBOOK
static void prefs_matcher_addressbook_select(void);
#endif
static void prefs_matcher_test_info(GtkWidget *widget, GtkWidget *parent);
enum {
@ -528,10 +530,7 @@ static void prefs_matcher_create(void)
GtkWidget *test_btn;
GtkWidget *addressbook_select_btn;
#if !GTK_CHECK_VERSION(3, 0, 0)
GtkWidget *color_optmenu;
#endif
static GdkGeometry geometry;
GtkSizeGroup *size_group;
@ -657,10 +656,13 @@ static void prefs_matcher_create(void)
addressbook_select_btn = gtk_button_new_with_label(_("Select ..."));
gtk_box_pack_start(GTK_BOX(upper_hbox), addressbook_select_btn, FALSE, FALSE, 0);
#ifndef USE_NEW_ADDRBOOK
g_signal_connect(G_OBJECT (addressbook_select_btn), "clicked",
G_CALLBACK(prefs_matcher_addressbook_select),
NULL);
#else
gtk_widget_set_sensitive(GTK_WIDGET(addressbook_select_btn), FALSE);
#endif
match_label = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(match_label), 1, 0.5);
gtk_table_attach(GTK_TABLE(table), match_label, 0, 1, 1, 2,
@ -833,10 +835,10 @@ static void prefs_matcher_create(void)
#endif
matcher.bool_op_combo = bool_op_combo;
matcher.test_btn = test_btn;
#ifndef USE_NEW_ADDRBOOK
matcher.addressbook_select_btn = addressbook_select_btn;
#if !GTK_CHECK_VERSION(3, 0, 0)
matcher.color_optmenu = color_optmenu;
#endif
matcher.color_optmenu = color_optmenu;
matcher.match_label = match_label;
matcher.criteria_label2 = criteria_label2;
matcher.headers_combo = headers_combo;
@ -2145,6 +2147,7 @@ static void prefs_matcher_test_info(GtkWidget *widget, GtkWidget *parent)
description_window_create(&test_desc_win);
}
#ifndef USE_NEW_ADDRBOOK
static void prefs_matcher_addressbook_select(void)
{
const gchar *folderpath = NULL;
@ -2157,7 +2160,7 @@ static void prefs_matcher_addressbook_select(void)
g_free(new_path);
}
}
#endif
/*
* list view

View file

@ -57,7 +57,12 @@
#include "colorlabel.h"
#include "inc.h"
#include "imap.h"
#include "addressbook.h"
#ifndef USE_NEW_ADDRBOOK
#include "addressbook.h"
#else
#include "addressbook-dbus.h"
#include "addressadd.h"
#endif
#include "addr_compl.h"
#include "folder_item_prefs.h"
#include "filtering.h"
@ -4626,8 +4631,13 @@ void summary_add_address(SummaryView *summaryview)
if (image)
picture = gtk_image_get_pixbuf(GTK_IMAGE(image));
#ifndef USE_NEW_ADDRBOOK
addressbook_add_contact(msginfo->fromname, from, NULL, picture);
#else
if (addressadd_selection(msginfo->fromname, from, NULL, picture)) {
debug_print( "addressbook_add_contact - added\n" );
}
#endif
if (image)
gtk_widget_destroy(image);
}
@ -7856,7 +7866,9 @@ void summary_harvest_address(SummaryView *summaryview)
continue;
msgList = g_list_append( msgList, GUINT_TO_POINTER( msginfo->msgnum ) );
}
addressbook_harvest( summaryview->folder_item, TRUE, msgList );
g_list_free( msgList );
}

View file

@ -55,7 +55,13 @@
#include "html.h"
#include "enriched.h"
#include "compose.h"
#include "addressbook.h"
#ifndef USE_NEW_ADDRBOOK
#include "addressbook.h"
#include "addrindex.h"
#else
#include "addressbook-dbus.h"
#include "addressadd.h"
#endif
#include "displayheader.h"
#include "account.h"
#include "mimeview.h"
@ -67,7 +73,6 @@
#include "inputdialog.h"
#include "timing.h"
#include "tags.h"
#include "addrindex.h"
static GdkColor quote_colors[3] = {
{(gulong)0, (gushort)0, (gushort)0, (gushort)0},
@ -1938,6 +1943,7 @@ void textview_show_icon(TextView *textview, const gchar *stock_id)
#if HAVE_LIBCOMPFACE
static void textview_show_xface(TextView *textview)
{
GtkAllocation allocation;
MsgInfo *msginfo = textview->messageview->msginfo;
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
int x = 0;
@ -1970,7 +1976,8 @@ static void textview_show_xface(TextView *textview)
gtk_widget_show(textview->image);
x = textview->text->allocation.width - WIDTH -5;
gtk_widget_get_allocation(textview->text, &allocation);
x = allocation.width - WIDTH -5;
gtk_text_view_add_child_in_window(text, textview->image,
GTK_TEXT_WINDOW_TEXT, x, 5);
@ -1988,6 +1995,7 @@ bail:
static void textview_save_contact_pic(TextView *textview)
{
#ifndef USE_NEW_ADDRBOOK
MsgInfo *msginfo = textview->messageview->msginfo;
gchar *filename = NULL;
GError *error = NULL;
@ -2011,11 +2019,14 @@ static void textview_save_contact_pic(TextView *textview)
}
}
g_free(filename);
#else
/* new address book */
#endif
}
static void textview_show_contact_pic(TextView *textview)
{
GtkAllocation allocation;
#ifndef USE_NEW_ADDRBOOK
MsgInfo *msginfo = textview->messageview->msginfo;
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
int x = 0;
@ -2067,8 +2078,7 @@ static void textview_show_contact_pic(TextView *textview)
gtk_widget_show(textview->image);
gtk_widget_get_allocation(textview->text, &allocation);
x = allocation.width - WIDTH -5;
x = textview->text->allocation.width - WIDTH -5;
gtk_text_view_add_child_in_window(text, textview->image,
GTK_TEXT_WINDOW_TEXT, x, 5);
@ -2080,7 +2090,9 @@ bail:
if (textview->image)
gtk_widget_destroy(textview->image);
textview->image = NULL;
#else
/* new address book */
#endif
}
static gint textview_tag_cmp_list(gconstpointer a, gconstpointer b)
@ -3064,6 +3076,7 @@ static void add_uri_to_addrbook_cb (GtkAction *action, TextView *textview)
GtkWidget *image = NULL;
GdkPixbuf *picture = NULL;
gboolean use_picture = FALSE;
if (uri == NULL)
return;
@ -3096,7 +3109,13 @@ static void add_uri_to_addrbook_cb (GtkAction *action, TextView *textview)
if (image)
picture = gtk_image_get_pixbuf(GTK_IMAGE(image));
#ifndef USE_NEW_ADDRBOOK
addressbook_add_contact( fromname, fromaddress, NULL, picture);
#else
if (addressadd_selection(fromname, fromaddress, NULL, picture)) {
debug_print( "addressbook_add_contact - added\n" );
}
#endif
g_free(fromaddress);
g_free(fromname);

View file

@ -57,6 +57,9 @@
#include "prefs_toolbar.h"
#include "alertpanel.h"
#include "imap.h"
#ifdef USE_NEW_ADDRBOOK
#include "addressbook-dbus.h"
#endif
/* elements */
#define TOOLBAR_TAG_INDEX "toolbar"
@ -1315,7 +1318,17 @@ static void toolbar_addrbook_cb(GtkWidget *widget, gpointer data)
default:
return;
}
#ifndef USE_NEW_ADDRBOOK
addressbook_open(compose);
#else
GError* error = NULL;
addressbook_connect_signals(compose);
addressbook_dbus_open(TRUE, &error);
if (error) {
g_warning("%s", error->message);
g_error_free(error);
}
#endif
}