claws-mail/src/addrindex.c

3218 lines
83 KiB
C
Raw Normal View History

2001-09-02 01:48:06 +02:00
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
* Copyright (C) 2001-2009 Match Grun and the Claws Mail team
2001-09-02 01:48:06 +02:00
*
* 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
2007-07-11 [colin] 2.10.0cvs16 * COPYING * README * autogen.sh * manual/claws-mail-manual.xml * manual/gpl.xml * manual/es/claws-mail-manual.xml * manual/es/gpl.xml * manual/fr/claws-mail-manual.xml * manual/fr/gpl.xml * manual/pl/gpl.xml * src/account.c * src/account.h * src/action.c * src/action.h * src/adbookbase.h * src/addr_compl.c * src/addr_compl.h * src/addrbook.c * src/addrbook.h * src/addrcache.c * src/addrcache.h * src/addrcindex.c * src/addrcindex.h * src/addrclip.c * src/addrclip.h * src/addrdefs.h * src/addressadd.c * src/addressadd.h * src/addressbook.c * src/addressbook.h * src/addressbook_foldersel.c * src/addressbook_foldersel.h * src/addressitem.h * src/addrgather.c * src/addrgather.h * src/addrharvest.c * src/addrharvest.h * src/addrindex.c * src/addrindex.h * src/addritem.c * src/addritem.h * src/addrquery.c * src/addrquery.h * src/addrselect.c * src/addrselect.h * src/alertpanel.c * src/alertpanel.h * src/browseldap.c * src/browseldap.h * src/codeconv.c * src/codeconv.h * src/compose.c * src/compose.h * src/crash.c * src/crash.h * src/customheader.c * src/customheader.h * src/displayheader.c * src/displayheader.h * src/editaddress.c * src/editaddress.h * src/editaddress_other_attributes_ldap.c * src/editaddress_other_attributes_ldap.h * src/editbook.c * src/editbook.h * src/editgroup.c * src/editgroup.h * src/editjpilot.c * src/editjpilot.h * src/editldap.c * src/editldap.h * src/editldap_basedn.c * src/editldap_basedn.h * src/edittags.c * src/edittags.h * src/editvcard.c * src/editvcard.h * src/enriched.c * src/enriched.h * src/exphtmldlg.c * src/exphtmldlg.h * src/expldifdlg.c * src/expldifdlg.h * src/export.c * src/export.h * src/exporthtml.c * src/exporthtml.h * src/exportldif.c * src/exportldif.h * src/filtering.c * src/filtering.h * src/folder.c * src/folder.h * src/folder_item_prefs.c * src/folder_item_prefs.h * src/foldersel.c * src/foldersel.h * src/folderutils.c * src/folderutils.h * src/folderview.c * src/folderview.h * src/gedit-print.c * src/gedit-print.h * src/grouplistdialog.c * src/grouplistdialog.h * src/headerview.c * src/headerview.h * src/html.c * src/html.h * src/image_viewer.c * src/image_viewer.h * src/imap.c * src/imap.h * src/imap_gtk.c * src/imap_gtk.h * src/import.c * src/import.h * src/importldif.c * src/importldif.h * src/importmutt.c * src/importmutt.h * src/importpine.c * src/importpine.h * src/inc.c * src/inc.h * src/jpilot.c * src/jpilot.h * src/ldapctrl.c * src/ldapctrl.h * src/ldaplocate.c * src/ldaplocate.h * src/ldapquery.c * src/ldapquery.h * src/ldapserver.c * src/ldapserver.h * src/ldapupdate.c * src/ldapupdate.h * src/ldaputil.c * src/ldaputil.h * src/ldif.c * src/ldif.h * src/localfolder.c * src/localfolder.h * src/main.c * src/main.h * src/mainwindow.c * src/mainwindow.h * src/manual.c * src/manual.h * src/matcher.c * src/matcher.h * src/matcher_parser.h * src/matcher_parser_lex.l * src/matcher_parser_parse.y * src/mbox.c * src/mbox.h * src/message_search.c * src/message_search.h * src/messageview.c * src/messageview.h * src/mh.c * src/mh.h * src/mh_gtk.c * src/mh_gtk.h * src/mimeview.c * src/mimeview.h * src/msgcache.c * src/msgcache.h * src/mutt.c * src/mutt.h * src/news.c * src/news.h * src/news_gtk.c * src/news_gtk.h * src/noticeview.c * src/noticeview.h * src/partial_download.c * src/partial_download.h * src/pine.c * src/pine.h * src/pop.c * src/pop.h * src/prefs_account.c * src/prefs_account.h * src/prefs_actions.c * src/prefs_actions.h * src/prefs_common.c * src/prefs_common.h * src/prefs_compose_writing.c * src/prefs_compose_writing.h * src/prefs_customheader.c * src/prefs_customheader.h * src/prefs_display_header.c * src/prefs_display_header.h * src/prefs_ext_prog.c * src/prefs_ext_prog.h * src/prefs_filtering.c * src/prefs_filtering.h * src/prefs_filtering_action.c * src/prefs_filtering_action.h * src/prefs_folder_column.c * src/prefs_folder_column.h * src/prefs_folder_item.c * src/prefs_folder_item.h * src/prefs_fonts.c * src/prefs_fonts.h * src/prefs_gtk.c * src/prefs_gtk.h * src/prefs_image_viewer.c * src/prefs_image_viewer.h * src/prefs_logging.c * src/prefs_logging.h * src/prefs_matcher.c * src/prefs_matcher.h * src/prefs_message.c * src/prefs_message.h * src/prefs_msg_colors.c * src/prefs_msg_colors.h * src/prefs_other.c * src/prefs_other.h * src/prefs_quote.c * src/prefs_quote.h * src/prefs_receive.c * src/prefs_receive.h * src/prefs_send.c * src/prefs_send.h * src/prefs_spelling.c * src/prefs_spelling.h * src/prefs_summaries.c * src/prefs_summaries.h * src/prefs_summary_column.c * src/prefs_summary_column.h * src/prefs_summary_open.c * src/prefs_summary_open.h * src/prefs_template.c * src/prefs_template.h * src/prefs_themes.c * src/prefs_themes.h * src/prefs_toolbar.c * src/prefs_toolbar.h * src/prefs_wrapping.c * src/prefs_wrapping.h * src/privacy.c * src/privacy.h * src/procheader.c * src/procheader.h * src/procmime.c * src/procmime.h * src/procmsg.c * src/procmsg.h * src/quote_fmt.c * src/quote_fmt_lex.l * src/quote_fmt_parse.y * src/recv.c * src/recv.h * src/remotefolder.c * src/remotefolder.h * src/send_message.c * src/send_message.h * src/setup.c * src/setup.h * src/simple-gettext.c * src/sourcewindow.c * src/sourcewindow.h * src/ssl_manager.c * src/ssl_manager.h * src/statusbar.c * src/statusbar.h * src/stock_pixmap.c * src/stock_pixmap.h * src/summary_search.c * src/summary_search.h * src/summaryview.c * src/summaryview.h * src/textview.c * src/textview.h * src/toolbar.c * src/toolbar.h * src/undo.c * src/undo.h * src/unmime.c * src/unmime.h * src/uri_opener.c * src/uri_opener.h * src/vcard.c * src/vcard.h * src/wizard.c * src/wizard.h * src/common/base64.c * src/common/base64.h * src/common/claws.c * src/common/claws.h * src/common/defs.h * src/common/fnmatch.c * src/common/fnmatch.h * src/common/fnmatch_loop.c * src/common/hooks.c * src/common/hooks.h * src/common/log.c * src/common/log.h * src/common/md5.c * src/common/md5.h * src/common/mgutils.c * src/common/mgutils.h * src/common/nntp.c * src/common/nntp.h * src/common/passcrypt.c * src/common/passcrypt.h.in * src/common/plugin.c * src/common/plugin.h * src/common/prefs.c * src/common/prefs.h * src/common/progressindicator.c * src/common/progressindicator.h * src/common/quoted-printable.c * src/common/quoted-printable.h * src/common/session.c * src/common/session.h * src/common/smtp.c * src/common/smtp.h * src/common/socket.c * src/common/socket.h * src/common/ssl.c * src/common/ssl.h * src/common/ssl_certificate.c * src/common/ssl_certificate.h * src/common/string_match.c * src/common/string_match.h * src/common/stringtable.c * src/common/stringtable.h * src/common/tags.c * src/common/tags.h * src/common/template.c * src/common/template.h * src/common/timing.h * src/common/utils.c * src/common/utils.h * src/common/uuencode.c * src/common/uuencode.h * src/common/version.h.in * src/common/w32_dirent.c * src/common/w32_reg.c * src/common/w32_signal.c * src/common/w32_stat.c * src/common/w32_stdlib.c * src/common/w32_string.c * src/common/w32_time.c * src/common/w32_unistd.c * src/common/w32_wait.c * src/common/w32lib.h * src/common/xml.c * src/common/xml.h * src/common/xmlprops.c * src/common/xmlprops.h * src/etpan/etpan-errors.h * src/etpan/etpan-thread-manager-types.h * src/etpan/etpan-thread-manager.c * src/etpan/etpan-thread-manager.h * src/etpan/imap-thread.c * src/etpan/imap-thread.h * src/gtk/about.c * src/gtk/about.h * src/gtk/colorlabel.c * src/gtk/colorlabel.h * src/gtk/colorsel.c * src/gtk/colorsel.h * src/gtk/combobox.c * src/gtk/combobox.h * src/gtk/description_window.c * src/gtk/description_window.h * src/gtk/filesel.c * src/gtk/filesel.h * src/gtk/foldersort.c * src/gtk/foldersort.h * src/gtk/gtkaspell.c * src/gtk/gtkaspell.h * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtkshruler.h * src/gtk/gtksourceprintjob.c * src/gtk/gtksourceprintjob.h * src/gtk/gtkutils.c * src/gtk/gtkutils.h * src/gtk/gtkvscrollbutton.c * src/gtk/gtkvscrollbutton.h * src/gtk/icon_legend.c * src/gtk/icon_legend.h * src/gtk/inputdialog.c * src/gtk/inputdialog.h * src/gtk/logwindow.c * src/gtk/logwindow.h * src/gtk/manage_window.c * src/gtk/manage_window.h * src/gtk/menu.c * src/gtk/menu.h * src/gtk/pluginwindow.c * src/gtk/pluginwindow.h * src/gtk/prefswindow.c * src/gtk/prefswindow.h * src/gtk/progressdialog.c * src/gtk/progressdialog.h * src/gtk/quicksearch.c * src/gtk/quicksearch.h * src/gtk/sslcertwindow.c * src/gtk/sslcertwindow.h * src/plugins/bogofilter/bogofilter.c * src/plugins/bogofilter/bogofilter.h * src/plugins/bogofilter/bogofilter_gtk.c * src/plugins/clamav/clamav_plugin.c * src/plugins/clamav/clamav_plugin.h * src/plugins/clamav/clamav_plugin_gtk.c * src/plugins/demo/demo.c * src/plugins/dillo_viewer/dillo_prefs.c * src/plugins/dillo_viewer/dillo_prefs.h * src/plugins/dillo_viewer/dillo_viewer.c * src/plugins/pgpcore/passphrase.c * src/plugins/pgpcore/passphrase.h * src/plugins/pgpcore/pgp_viewer.c * src/plugins/pgpcore/pgp_viewer.h * src/plugins/pgpcore/plugin.c * src/plugins/pgpcore/prefs_gpg.c * src/plugins/pgpcore/prefs_gpg.h * src/plugins/pgpcore/select-keys.c * src/plugins/pgpcore/select-keys.h * src/plugins/pgpcore/sgpgme.c * src/plugins/pgpcore/sgpgme.h * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpinline/pgpinline.h * src/plugins/pgpinline/plugin.c * src/plugins/pgpmime/pgpmime.c * src/plugins/pgpmime/pgpmime.h * src/plugins/pgpmime/plugin.c * src/plugins/spamassassin/spamassassin.c * src/plugins/spamassassin/spamassassin.h * src/plugins/spamassassin/spamassassin_gtk.c * src/plugins/trayicon/trayicon.c * src/plugins/trayicon/trayicon_prefs.c * src/plugins/trayicon/trayicon_prefs.h * src/plugins/trayicon/libeggtrayicon/eggtrayicon.c * src/plugins/trayicon/libeggtrayicon/eggtrayicon.h * src/plugins/trayicon/libeggtrayicon/gtk2-funcs.h * src/plugins/trayicon/libeggtrayicon/gtkplugxembed.c * src/plugins/trayicon/libeggtrayicon/gtkplugxembed.h * tools/OOo2claws-mail.pl * tools/README.sylprint * tools/acroread2claws-mail.pl * tools/claws-mail-compose-insert-files.pl * tools/convert_mbox.pl * tools/filter_conv.pl * tools/filter_conv_new.pl * tools/fix_date.sh * tools/freshmeat_search.pl * tools/google_search.pl * tools/kmail-mailbox2claws-mail.pl * tools/kmail2claws-mail.pl * tools/kmail2claws-mail_v2.pl * tools/mairix.sh * tools/make.themes.project * tools/multiwebsearch.pl * tools/nautilus2claws-mail.sh * tools/outlook2claws-mail.pl * tools/textviewer.sh * tools/thunderbird-filters-convertor.pl * tools/update-po * tools/uuooffice * tools/vcard2xml.py * tools/kdeservicemenu/claws-mail-kdeservicemenu.pl Upgrade to GPLv3 or later.
2007-07-11 18:38:12 +02:00
* the Free Software Foundation; either version 3 of the License, or
2001-09-02 01:48:06 +02:00
* (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
2007-07-11 [colin] 2.10.0cvs16 * COPYING * README * autogen.sh * manual/claws-mail-manual.xml * manual/gpl.xml * manual/es/claws-mail-manual.xml * manual/es/gpl.xml * manual/fr/claws-mail-manual.xml * manual/fr/gpl.xml * manual/pl/gpl.xml * src/account.c * src/account.h * src/action.c * src/action.h * src/adbookbase.h * src/addr_compl.c * src/addr_compl.h * src/addrbook.c * src/addrbook.h * src/addrcache.c * src/addrcache.h * src/addrcindex.c * src/addrcindex.h * src/addrclip.c * src/addrclip.h * src/addrdefs.h * src/addressadd.c * src/addressadd.h * src/addressbook.c * src/addressbook.h * src/addressbook_foldersel.c * src/addressbook_foldersel.h * src/addressitem.h * src/addrgather.c * src/addrgather.h * src/addrharvest.c * src/addrharvest.h * src/addrindex.c * src/addrindex.h * src/addritem.c * src/addritem.h * src/addrquery.c * src/addrquery.h * src/addrselect.c * src/addrselect.h * src/alertpanel.c * src/alertpanel.h * src/browseldap.c * src/browseldap.h * src/codeconv.c * src/codeconv.h * src/compose.c * src/compose.h * src/crash.c * src/crash.h * src/customheader.c * src/customheader.h * src/displayheader.c * src/displayheader.h * src/editaddress.c * src/editaddress.h * src/editaddress_other_attributes_ldap.c * src/editaddress_other_attributes_ldap.h * src/editbook.c * src/editbook.h * src/editgroup.c * src/editgroup.h * src/editjpilot.c * src/editjpilot.h * src/editldap.c * src/editldap.h * src/editldap_basedn.c * src/editldap_basedn.h * src/edittags.c * src/edittags.h * src/editvcard.c * src/editvcard.h * src/enriched.c * src/enriched.h * src/exphtmldlg.c * src/exphtmldlg.h * src/expldifdlg.c * src/expldifdlg.h * src/export.c * src/export.h * src/exporthtml.c * src/exporthtml.h * src/exportldif.c * src/exportldif.h * src/filtering.c * src/filtering.h * src/folder.c * src/folder.h * src/folder_item_prefs.c * src/folder_item_prefs.h * src/foldersel.c * src/foldersel.h * src/folderutils.c * src/folderutils.h * src/folderview.c * src/folderview.h * src/gedit-print.c * src/gedit-print.h * src/grouplistdialog.c * src/grouplistdialog.h * src/headerview.c * src/headerview.h * src/html.c * src/html.h * src/image_viewer.c * src/image_viewer.h * src/imap.c * src/imap.h * src/imap_gtk.c * src/imap_gtk.h * src/import.c * src/import.h * src/importldif.c * src/importldif.h * src/importmutt.c * src/importmutt.h * src/importpine.c * src/importpine.h * src/inc.c * src/inc.h * src/jpilot.c * src/jpilot.h * src/ldapctrl.c * src/ldapctrl.h * src/ldaplocate.c * src/ldaplocate.h * src/ldapquery.c * src/ldapquery.h * src/ldapserver.c * src/ldapserver.h * src/ldapupdate.c * src/ldapupdate.h * src/ldaputil.c * src/ldaputil.h * src/ldif.c * src/ldif.h * src/localfolder.c * src/localfolder.h * src/main.c * src/main.h * src/mainwindow.c * src/mainwindow.h * src/manual.c * src/manual.h * src/matcher.c * src/matcher.h * src/matcher_parser.h * src/matcher_parser_lex.l * src/matcher_parser_parse.y * src/mbox.c * src/mbox.h * src/message_search.c * src/message_search.h * src/messageview.c * src/messageview.h * src/mh.c * src/mh.h * src/mh_gtk.c * src/mh_gtk.h * src/mimeview.c * src/mimeview.h * src/msgcache.c * src/msgcache.h * src/mutt.c * src/mutt.h * src/news.c * src/news.h * src/news_gtk.c * src/news_gtk.h * src/noticeview.c * src/noticeview.h * src/partial_download.c * src/partial_download.h * src/pine.c * src/pine.h * src/pop.c * src/pop.h * src/prefs_account.c * src/prefs_account.h * src/prefs_actions.c * src/prefs_actions.h * src/prefs_common.c * src/prefs_common.h * src/prefs_compose_writing.c * src/prefs_compose_writing.h * src/prefs_customheader.c * src/prefs_customheader.h * src/prefs_display_header.c * src/prefs_display_header.h * src/prefs_ext_prog.c * src/prefs_ext_prog.h * src/prefs_filtering.c * src/prefs_filtering.h * src/prefs_filtering_action.c * src/prefs_filtering_action.h * src/prefs_folder_column.c * src/prefs_folder_column.h * src/prefs_folder_item.c * src/prefs_folder_item.h * src/prefs_fonts.c * src/prefs_fonts.h * src/prefs_gtk.c * src/prefs_gtk.h * src/prefs_image_viewer.c * src/prefs_image_viewer.h * src/prefs_logging.c * src/prefs_logging.h * src/prefs_matcher.c * src/prefs_matcher.h * src/prefs_message.c * src/prefs_message.h * src/prefs_msg_colors.c * src/prefs_msg_colors.h * src/prefs_other.c * src/prefs_other.h * src/prefs_quote.c * src/prefs_quote.h * src/prefs_receive.c * src/prefs_receive.h * src/prefs_send.c * src/prefs_send.h * src/prefs_spelling.c * src/prefs_spelling.h * src/prefs_summaries.c * src/prefs_summaries.h * src/prefs_summary_column.c * src/prefs_summary_column.h * src/prefs_summary_open.c * src/prefs_summary_open.h * src/prefs_template.c * src/prefs_template.h * src/prefs_themes.c * src/prefs_themes.h * src/prefs_toolbar.c * src/prefs_toolbar.h * src/prefs_wrapping.c * src/prefs_wrapping.h * src/privacy.c * src/privacy.h * src/procheader.c * src/procheader.h * src/procmime.c * src/procmime.h * src/procmsg.c * src/procmsg.h * src/quote_fmt.c * src/quote_fmt_lex.l * src/quote_fmt_parse.y * src/recv.c * src/recv.h * src/remotefolder.c * src/remotefolder.h * src/send_message.c * src/send_message.h * src/setup.c * src/setup.h * src/simple-gettext.c * src/sourcewindow.c * src/sourcewindow.h * src/ssl_manager.c * src/ssl_manager.h * src/statusbar.c * src/statusbar.h * src/stock_pixmap.c * src/stock_pixmap.h * src/summary_search.c * src/summary_search.h * src/summaryview.c * src/summaryview.h * src/textview.c * src/textview.h * src/toolbar.c * src/toolbar.h * src/undo.c * src/undo.h * src/unmime.c * src/unmime.h * src/uri_opener.c * src/uri_opener.h * src/vcard.c * src/vcard.h * src/wizard.c * src/wizard.h * src/common/base64.c * src/common/base64.h * src/common/claws.c * src/common/claws.h * src/common/defs.h * src/common/fnmatch.c * src/common/fnmatch.h * src/common/fnmatch_loop.c * src/common/hooks.c * src/common/hooks.h * src/common/log.c * src/common/log.h * src/common/md5.c * src/common/md5.h * src/common/mgutils.c * src/common/mgutils.h * src/common/nntp.c * src/common/nntp.h * src/common/passcrypt.c * src/common/passcrypt.h.in * src/common/plugin.c * src/common/plugin.h * src/common/prefs.c * src/common/prefs.h * src/common/progressindicator.c * src/common/progressindicator.h * src/common/quoted-printable.c * src/common/quoted-printable.h * src/common/session.c * src/common/session.h * src/common/smtp.c * src/common/smtp.h * src/common/socket.c * src/common/socket.h * src/common/ssl.c * src/common/ssl.h * src/common/ssl_certificate.c * src/common/ssl_certificate.h * src/common/string_match.c * src/common/string_match.h * src/common/stringtable.c * src/common/stringtable.h * src/common/tags.c * src/common/tags.h * src/common/template.c * src/common/template.h * src/common/timing.h * src/common/utils.c * src/common/utils.h * src/common/uuencode.c * src/common/uuencode.h * src/common/version.h.in * src/common/w32_dirent.c * src/common/w32_reg.c * src/common/w32_signal.c * src/common/w32_stat.c * src/common/w32_stdlib.c * src/common/w32_string.c * src/common/w32_time.c * src/common/w32_unistd.c * src/common/w32_wait.c * src/common/w32lib.h * src/common/xml.c * src/common/xml.h * src/common/xmlprops.c * src/common/xmlprops.h * src/etpan/etpan-errors.h * src/etpan/etpan-thread-manager-types.h * src/etpan/etpan-thread-manager.c * src/etpan/etpan-thread-manager.h * src/etpan/imap-thread.c * src/etpan/imap-thread.h * src/gtk/about.c * src/gtk/about.h * src/gtk/colorlabel.c * src/gtk/colorlabel.h * src/gtk/colorsel.c * src/gtk/colorsel.h * src/gtk/combobox.c * src/gtk/combobox.h * src/gtk/description_window.c * src/gtk/description_window.h * src/gtk/filesel.c * src/gtk/filesel.h * src/gtk/foldersort.c * src/gtk/foldersort.h * src/gtk/gtkaspell.c * src/gtk/gtkaspell.h * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtkshruler.h * src/gtk/gtksourceprintjob.c * src/gtk/gtksourceprintjob.h * src/gtk/gtkutils.c * src/gtk/gtkutils.h * src/gtk/gtkvscrollbutton.c * src/gtk/gtkvscrollbutton.h * src/gtk/icon_legend.c * src/gtk/icon_legend.h * src/gtk/inputdialog.c * src/gtk/inputdialog.h * src/gtk/logwindow.c * src/gtk/logwindow.h * src/gtk/manage_window.c * src/gtk/manage_window.h * src/gtk/menu.c * src/gtk/menu.h * src/gtk/pluginwindow.c * src/gtk/pluginwindow.h * src/gtk/prefswindow.c * src/gtk/prefswindow.h * src/gtk/progressdialog.c * src/gtk/progressdialog.h * src/gtk/quicksearch.c * src/gtk/quicksearch.h * src/gtk/sslcertwindow.c * src/gtk/sslcertwindow.h * src/plugins/bogofilter/bogofilter.c * src/plugins/bogofilter/bogofilter.h * src/plugins/bogofilter/bogofilter_gtk.c * src/plugins/clamav/clamav_plugin.c * src/plugins/clamav/clamav_plugin.h * src/plugins/clamav/clamav_plugin_gtk.c * src/plugins/demo/demo.c * src/plugins/dillo_viewer/dillo_prefs.c * src/plugins/dillo_viewer/dillo_prefs.h * src/plugins/dillo_viewer/dillo_viewer.c * src/plugins/pgpcore/passphrase.c * src/plugins/pgpcore/passphrase.h * src/plugins/pgpcore/pgp_viewer.c * src/plugins/pgpcore/pgp_viewer.h * src/plugins/pgpcore/plugin.c * src/plugins/pgpcore/prefs_gpg.c * src/plugins/pgpcore/prefs_gpg.h * src/plugins/pgpcore/select-keys.c * src/plugins/pgpcore/select-keys.h * src/plugins/pgpcore/sgpgme.c * src/plugins/pgpcore/sgpgme.h * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpinline/pgpinline.h * src/plugins/pgpinline/plugin.c * src/plugins/pgpmime/pgpmime.c * src/plugins/pgpmime/pgpmime.h * src/plugins/pgpmime/plugin.c * src/plugins/spamassassin/spamassassin.c * src/plugins/spamassassin/spamassassin.h * src/plugins/spamassassin/spamassassin_gtk.c * src/plugins/trayicon/trayicon.c * src/plugins/trayicon/trayicon_prefs.c * src/plugins/trayicon/trayicon_prefs.h * src/plugins/trayicon/libeggtrayicon/eggtrayicon.c * src/plugins/trayicon/libeggtrayicon/eggtrayicon.h * src/plugins/trayicon/libeggtrayicon/gtk2-funcs.h * src/plugins/trayicon/libeggtrayicon/gtkplugxembed.c * src/plugins/trayicon/libeggtrayicon/gtkplugxembed.h * tools/OOo2claws-mail.pl * tools/README.sylprint * tools/acroread2claws-mail.pl * tools/claws-mail-compose-insert-files.pl * tools/convert_mbox.pl * tools/filter_conv.pl * tools/filter_conv_new.pl * tools/fix_date.sh * tools/freshmeat_search.pl * tools/google_search.pl * tools/kmail-mailbox2claws-mail.pl * tools/kmail2claws-mail.pl * tools/kmail2claws-mail_v2.pl * tools/mairix.sh * tools/make.themes.project * tools/multiwebsearch.pl * tools/nautilus2claws-mail.sh * tools/outlook2claws-mail.pl * tools/textviewer.sh * tools/thunderbird-filters-convertor.pl * tools/update-po * tools/uuooffice * tools/vcard2xml.py * tools/kdeservicemenu/claws-mail-kdeservicemenu.pl Upgrade to GPLv3 or later.
2007-07-11 18:38:12 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
2001-09-02 01:48:06 +02:00
*/
/*
* General functions for accessing address index file.
*/
2001-09-18 11:36:32 +02:00
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "defs.h"
2001-09-02 01:48:06 +02:00
#include <glib.h>
2005-02-10 [paul] 1.0.1cvs3.2 * AUTHORS * Makefile.am * autogen.sh * configure.ac * config/mkinstalldirs * intl/.cvsignore * intl/ChangeLog * intl/VERSION * intl/bindtextdom.c * intl/config.charset * intl/dcgettext.c * intl/dcigettext.c * intl/dcngettext.c * intl/dgettext.c * intl/dngettext.c * intl/eval-plural.h * intl/explodename.c * intl/finddomain.c * intl/gettext.c * intl/gettextP.h * intl/gmo.h * intl/hash-string.h * intl/intl-compat.c * intl/l10nflist.c * intl/libgnuintl.h.in * intl/loadinfo.h * intl/loadmsgcat.c * intl/localcharset.c * intl/localcharset.h * intl/locale.alias * intl/localealias.c * intl/localename.c * intl/log.c * intl/ngettext.c * intl/os2compat.c * intl/os2compat.h * intl/osdep.c * intl/plural-exp.c * intl/plural-exp.h * intl/plural.c * intl/plural.y * intl/ref-add.sin * intl/ref-del.sin * intl/relocatable.c * intl/relocatable.h * intl/textdomain.c * m4/Makefile.am * po/Makefile.in.in * src/Makefile.am * src/account.c * src/action.c * src/addr_compl.c * src/addressadd.c * src/addressbook.c * src/addrgather.c * src/addrindex.c * src/alertpanel.c * src/browseldap.c * src/codeconv.c * src/codeconv.h * src/compose.c * src/compose.h * src/crash.c * src/editaddress.c * src/editbook.c * src/editgroup.c * src/editjpilot.c * src/editldap.c * src/editldap_basedn.c * src/editvcard.c * src/exphtmldlg.c * src/expldifdlg.c * src/export.c * src/exporthtml.c * src/filtering.c * src/folder.c * src/folder_item_prefs.c * src/foldersel.c * src/folderview.c * src/grouplistdialog.c * src/headerview.c * src/imap.c * src/imap_gtk.c * src/import.c * src/importldif.c * src/importmutt.c * src/importpine.c * src/inc.c * src/ldif.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/message_search.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/partial_download.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_customheader.c * src/prefs_display_header.c * src/prefs_ext_prog.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_item.c * src/prefs_fonts.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_msg_colors.c * src/prefs_spelling.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/prefs_wrapping.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/recv.c * src/send_message.c * src/setup.c * src/sourcewindow.c * src/ssl_manager.c * src/statusbar.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/wizard.c * src/common/nntp.c * src/common/plugin.c * src/common/smtp.c * src/common/ssl.c * src/common/ssl_certificate.c * src/common/string_match.c * src/common/sylpheed.c * src/common/template.c * src/common/utils.c * src/gtk/about.c * src/gtk/colorlabel.c * src/gtk/description_window.c * src/gtk/filesel.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkutils.c * src/gtk/inputdialog.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/progressdialog.c * src/gtk/quicksearch.c * src/gtk/sslcertwindow.c * src/plugins/clamav/clamav_plugin.c * src/plugins/clamav/clamav_plugin_gtk.c * src/plugins/demo/demo.c * src/plugins/dillo_viewer/dillo_prefs.c * src/plugins/dillo_viewer/dillo_viewer.c * src/plugins/image_viewer/plugin.c * src/plugins/image_viewer/viewer.c * src/plugins/image_viewer/viewerprefs.c * src/plugins/mathml_viewer/mathml_viewer.c * src/plugins/pgpmime/passphrase.c * src/plugins/pgpmime/plugin.c * src/plugins/pgpmime/prefs_gpg.c * src/plugins/pgpmime/select-keys.c * src/plugins/pgpmime/sgpgme.c * src/plugins/spamassassin/spamassassin.c * src/plugins/spamassassin/spamassassin_gtk.c * src/plugins/trayicon/trayicon.c sync with main (revision 104)
2005-02-10 13:06:07 +01:00
#include <glib/gi18n.h>
2001-09-02 01:48:06 +02:00
#include "mgutils.h"
#include "addritem.h"
#include "addrcache.h"
#include "addrbook.h"
#include "addressbook.h"
2001-09-02 01:48:06 +02:00
#include "addrindex.h"
#include "xml.h"
2003-06-21 08:23:00 +02:00
#include "addrquery.h"
#include "addr_compl.h"
#include "utils.h"
#include "alertpanel.h"
2001-09-02 01:48:06 +02:00
#ifndef DEV_STANDALONE
#include "prefs_gtk.h"
2001-09-06 12:24:20 +02:00
#include "codeconv.h"
2001-09-02 01:48:06 +02:00
#endif
#include "vcard.h"
#ifdef USE_JPILOT
#include "jpilot.h"
#endif
#ifdef USE_LDAP
2003-06-21 08:23:00 +02:00
#include "ldapserver.h"
#include "ldapctrl.h"
#include "ldapquery.h"
#include "ldapupdate.h"
#include "ldaputil.h"
2001-09-02 01:48:06 +02:00
#endif
#define TAG_ADDRESS_INDEX "addressbook"
#define TAG_IF_ADDRESS_BOOK "book_list"
#define TAG_IF_VCARD "vcard_list"
#define TAG_IF_JPILOT "jpilot_list"
#define TAG_IF_LDAP "ldap_list"
#define TAG_DS_ADDRESS_BOOK "book"
#define TAG_DS_VCARD "vcard"
#define TAG_DS_JPILOT "jpilot"
#define TAG_DS_LDAP "server"
2001-09-30 13:07:34 +02:00
/* XML Attribute names */
2001-09-02 01:48:06 +02:00
#define ATTAG_BOOK_NAME "name"
#define ATTAG_BOOK_FILE "file"
#define ATTAG_VCARD_NAME "name"
#define ATTAG_VCARD_FILE "file"
#define ATTAG_JPILOT_NAME "name"
#define ATTAG_JPILOT_FILE "file"
#define ATTAG_JPILOT_CUSTOM_1 "custom-1"
#define ATTAG_JPILOT_CUSTOM_2 "custom-2"
#define ATTAG_JPILOT_CUSTOM_3 "custom-3"
#define ATTAG_JPILOT_CUSTOM_4 "custom-4"
#define ATTAG_JPILOT_CUSTOM "custom-"
#define ATTAG_LDAP_NAME "name"
#define ATTAG_LDAP_HOST "host"
#define ATTAG_LDAP_PORT "port"
#define ATTAG_LDAP_BASE_DN "base-dn"
#define ATTAG_LDAP_BIND_DN "bind-dn"
#define ATTAG_LDAP_BIND_PASS "bind-pass"
#define ATTAG_LDAP_CRITERIA "criteria"
#define ATTAG_LDAP_MAX_ENTRY "max-entry"
#define ATTAG_LDAP_TIMEOUT "timeout"
2003-06-21 08:23:00 +02:00
#define ATTAG_LDAP_MAX_AGE "max-age"
#define ATTAG_LDAP_DYN_SEARCH "dyn-search"
2004-01-12 22:28:31 +01:00
#define ATTAG_LDAP_MATCH_OPT "match-opt"
2004-05-10 12:22:28 +02:00
#define ATTAG_LDAP_ENABLE_TLS "enable-tls"
#define ATTAG_LDAP_ENABLE_SSL "enable-ssl"
2003-06-21 08:23:00 +02:00
#define ELTAG_LDAP_ATTR_SRCH "attribute"
#define ATTAG_LDAP_ATTR_NAME "name"
2004-01-12 22:28:31 +01:00
/* Attribute values */
#define ATVAL_BOOLEAN_YES "yes"
#define ATVAL_BOOLEAN_NO "no"
#define ATVAL_LDAP_MATCH_BEGIN "begin-with"
#define ATVAL_LDAP_MATCH_CONTAINS "contains"
2003-06-21 08:23:00 +02:00
/* New attributes */
#define ATTAG_LDAP_DEFAULT "default"
2001-09-02 01:48:06 +02:00
#define DISP_NEW_COMMON _("Common addresses")
#define DISP_NEW_PERSONAL _("Personal addresses")
2001-09-02 01:48:06 +02:00
2001-09-30 13:07:34 +02:00
/* Old address book */
2001-09-02 01:48:06 +02:00
#define TAG_IF_OLD_COMMON "common_address"
#define TAG_IF_OLD_PERSONAL "personal_address"
2001-09-30 13:07:34 +02:00
#define DISP_OLD_COMMON _("Common address")
#define DISP_OLD_PERSONAL _("Personal address")
2001-09-02 01:48:06 +02:00
2004-01-12 22:28:31 +01:00
/**
* Singleton object.
*/
static AddressIndex *_addressIndex_ = NULL;
2003-06-21 08:23:00 +02:00
/*
* Define attribute name-value pair.
*/
2001-09-02 01:48:06 +02:00
typedef struct _AddressIfAttr AddressIfAttrib;
struct _AddressIfAttr {
gchar *name;
gchar *value;
};
static AddressDataSource *addrindex_create_datasource ( AddressIfType ifType );
static GList *addrindex_ds_get_all_persons ( AddressDataSource *ds );
static GList *addrindex_ds_get_all_groups ( AddressDataSource *ds );
static AddressDataSource *addrindex_get_datasource ( AddressIndex *addrIndex,
const gchar *cacheID );
static AddressInterface *addrindex_get_interface ( AddressIndex *addrIndex,
AddressIfType ifType );
static gint addrindex_write_to ( AddressIndex *addrIndex,
const gchar *newFile );
2001-09-02 01:48:06 +02:00
/*
2003-06-21 08:23:00 +02:00
* Define DOM fragment.
*/
typedef struct _AddressIfFrag AddressIfFragment;
struct _AddressIfFrag {
gchar *name;
GList *children;
GList *attributes;
};
/**
* Build interface with default values.
*
* \param type Interface type.
* \param name Interface name.
* \param tagIf XML tag name for interface in address index file.
* \param tagDS XML tag name for datasource in address index file.
* \return Address interface object.
2001-09-02 01:48:06 +02:00
*/
2003-06-21 08:23:00 +02:00
static AddressInterface *addrindex_create_interface(
gint type, gchar *name, gchar *tagIf, gchar *tagDS )
{
2001-09-02 01:48:06 +02:00
AddressInterface *iface = g_new0( AddressInterface, 1 );
2003-01-02 02:56:30 +01:00
2001-09-02 01:48:06 +02:00
ADDRITEM_TYPE(iface) = ITEMTYPE_INTERFACE;
ADDRITEM_ID(iface) = NULL;
ADDRITEM_NAME(iface) = g_strdup( name );
ADDRITEM_PARENT(iface) = NULL;
ADDRITEM_SUBTYPE(iface) = type;
iface->type = type;
iface->name = g_strdup( name );
iface->listTag = g_strdup( tagIf );
iface->itemTag = g_strdup( tagDS );
iface->legacyFlag = FALSE;
iface->haveLibrary = TRUE;
iface->useInterface = TRUE;
iface->readOnly = TRUE;
2003-06-21 08:23:00 +02:00
/* Set callbacks to NULL values - override for each interface */
2001-09-02 01:48:06 +02:00
iface->getAccessFlag = NULL;
iface->getModifyFlag = NULL;
iface->getReadFlag = NULL;
iface->getStatusCode = NULL;
iface->getReadData = NULL;
iface->getRootFolder = NULL;
iface->getListFolder = NULL;
iface->getListPerson = NULL;
iface->getAllPersons = NULL;
2001-09-24 07:42:50 +02:00
iface->getAllGroups = NULL;
2001-09-02 01:48:06 +02:00
iface->getName = NULL;
iface->listSource = NULL;
2003-06-21 08:23:00 +02:00
/* Search stuff */
iface->externalQuery = FALSE;
iface->searchOrder = 0; /* Ignored */
iface->startSearch = NULL;
iface->stopSearch = NULL;
2001-09-02 01:48:06 +02:00
return iface;
}
2003-06-21 08:23:00 +02:00
/**
* Build table of of all address book interfaces.
* \param addrIndex Address index object.
*/
2001-09-02 01:48:06 +02:00
static void addrindex_build_if_list( AddressIndex *addrIndex ) {
AddressInterface *iface;
2003-06-21 08:23:00 +02:00
/* Create intrinsic XML address book interface */
iface = addrindex_create_interface(
ADDR_IF_BOOK, "Address Book", TAG_IF_ADDRESS_BOOK,
TAG_DS_ADDRESS_BOOK );
2001-09-02 01:48:06 +02:00
iface->readOnly = FALSE;
iface->getModifyFlag = ( void * ) addrbook_get_modified;
iface->getAccessFlag = ( void * ) addrbook_get_accessed;
iface->getReadFlag = ( void * ) addrbook_get_read_flag;
iface->getStatusCode = ( void * ) addrbook_get_status;
iface->getReadData = ( void * ) addrbook_read_data;
iface->getRootFolder = ( void * ) addrbook_get_root_folder;
iface->getListFolder = ( void * ) addrbook_get_list_folder;
iface->getListPerson = ( void * ) addrbook_get_list_person;
iface->getAllPersons = ( void * ) addrbook_get_all_persons;
iface->getAllGroups = ( void * ) addrbook_get_all_groups;
2001-09-02 01:48:06 +02:00
iface->getName = ( void * ) addrbook_get_name;
iface->setAccessFlag = ( void * ) addrbook_set_accessed;
2003-06-21 08:23:00 +02:00
iface->searchOrder = 0;
/* Add to list of interfaces in address book */
addrIndex->interfaceList =
g_list_append( addrIndex->interfaceList, iface );
2001-09-02 01:48:06 +02:00
ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
2003-06-21 08:23:00 +02:00
/* Create vCard interface */
iface = addrindex_create_interface(
ADDR_IF_VCARD, "vCard", TAG_IF_VCARD, TAG_DS_VCARD );
2001-09-02 01:48:06 +02:00
iface->getModifyFlag = ( void * ) vcard_get_modified;
iface->getAccessFlag = ( void * ) vcard_get_accessed;
iface->getReadFlag = ( void * ) vcard_get_read_flag;
iface->getStatusCode = ( void * ) vcard_get_status;
iface->getReadData = ( void * ) vcard_read_data;
iface->getRootFolder = ( void * ) vcard_get_root_folder;
iface->getListFolder = ( void * ) vcard_get_list_folder;
iface->getListPerson = ( void * ) vcard_get_list_person;
iface->getAllPersons = ( void * ) vcard_get_all_persons;
iface->getName = ( void * ) vcard_get_name;
iface->setAccessFlag = ( void * ) vcard_set_accessed;
2003-06-21 08:23:00 +02:00
iface->searchOrder = 0;
addrIndex->interfaceList =
g_list_append( addrIndex->interfaceList, iface );
2001-09-02 01:48:06 +02:00
ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
2003-06-21 08:23:00 +02:00
/* Create JPilot interface */
iface = addrindex_create_interface(
ADDR_IF_JPILOT, "J-Pilot", TAG_IF_JPILOT,
TAG_DS_JPILOT );
2001-09-02 01:48:06 +02:00
#ifdef USE_JPILOT
iface->haveLibrary = jpilot_test_pilot_lib();
2001-09-02 03:09:09 +02:00
iface->useInterface = iface->haveLibrary;
2001-09-02 01:48:06 +02:00
iface->getModifyFlag = ( void * ) jpilot_get_modified;
iface->getAccessFlag = ( void * ) jpilot_get_accessed;
iface->getReadFlag = ( void * ) jpilot_get_read_flag;
iface->getStatusCode = ( void * ) jpilot_get_status;
iface->getReadData = ( void * ) jpilot_read_data;
iface->getRootFolder = ( void * ) jpilot_get_root_folder;
iface->getListFolder = ( void * ) jpilot_get_list_folder;
iface->getListPerson = ( void * ) jpilot_get_list_person;
iface->getAllPersons = ( void * ) jpilot_get_all_persons;
iface->getName = ( void * ) jpilot_get_name;
iface->setAccessFlag = ( void * ) jpilot_set_accessed;
2003-06-21 08:23:00 +02:00
iface->searchOrder = 0;
2001-09-02 01:48:06 +02:00
#else
iface->useInterface = FALSE;
iface->haveLibrary = FALSE;
#endif
2003-06-21 08:23:00 +02:00
addrIndex->interfaceList =
g_list_append( addrIndex->interfaceList, iface );
2001-09-02 01:48:06 +02:00
ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
2003-06-21 08:23:00 +02:00
/* Create LDAP interface */
iface = addrindex_create_interface(
ADDR_IF_LDAP, "LDAP", TAG_IF_LDAP, TAG_DS_LDAP );
2001-09-02 01:48:06 +02:00
#ifdef USE_LDAP
iface->readOnly = FALSE;
2003-06-21 08:23:00 +02:00
/* iface->haveLibrary = ldapsvr_test_ldap_lib(); */
iface->haveLibrary = ldaputil_test_ldap_lib();
2001-09-02 03:09:09 +02:00
iface->useInterface = iface->haveLibrary;
iface->getModifyFlag = ( void * ) ldapsvr_get_modified;
2003-06-21 08:23:00 +02:00
iface->getAccessFlag = ( void * ) ldapsvr_get_accessed;
iface->getReadFlag = ( void * ) ldapsvr_get_read_flag;
2003-06-21 08:23:00 +02:00
iface->getStatusCode = ( void * ) ldapsvr_get_status;
iface->getReadData = ( void * ) ldapsvr_read_data;
2003-06-21 08:23:00 +02:00
iface->getRootFolder = ( void * ) ldapsvr_get_root_folder;
iface->getListFolder = ( void * ) ldapsvr_get_list_folder;
iface->getListPerson = ( void * ) ldapsvr_get_list_person;
iface->getName = ( void * ) ldapsvr_get_name;
iface->setAccessFlag = ( void * ) ldapsvr_set_accessed;
iface->externalQuery = TRUE;
iface->searchOrder = 1;
2001-09-02 01:48:06 +02:00
#else
iface->useInterface = FALSE;
iface->haveLibrary = FALSE;
#endif
2003-06-21 08:23:00 +02:00
addrIndex->interfaceList =
g_list_append( addrIndex->interfaceList, iface );
2001-09-02 01:48:06 +02:00
ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
2003-06-21 08:23:00 +02:00
/* Two old legacy data sources (pre 0.7.0) */
iface = addrindex_create_interface(
ADDR_IF_COMMON, "Old Address - common",
TAG_IF_OLD_COMMON, NULL );
2001-09-02 01:48:06 +02:00
iface->legacyFlag = TRUE;
2003-06-21 08:23:00 +02:00
addrIndex->interfaceList =
g_list_append( addrIndex->interfaceList, iface );
2001-09-02 01:48:06 +02:00
ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
iface = addrindex_create_interface(
ADDR_IF_COMMON, "Old Address - personal",
TAG_IF_OLD_PERSONAL, NULL );
2001-09-02 01:48:06 +02:00
iface->legacyFlag = TRUE;
2003-06-21 08:23:00 +02:00
addrIndex->interfaceList =
g_list_append( addrIndex->interfaceList, iface );
2001-09-02 01:48:06 +02:00
ADDRITEM_PARENT(iface) = ADDRITEM_OBJECT(addrIndex);
}
2003-06-21 08:23:00 +02:00
/**
* Free DOM fragment.
* \param fragment Fragment to free.
*/
static void addrindex_free_fragment( AddressIfFragment *fragment ) {
2003-06-21 08:23:00 +02:00
GList *node;
/* Free children */
node = fragment->children;
while( node ) {
AddressIfFragment *child = node->data;
addrindex_free_fragment( child );
node->data = NULL;
node = g_list_next( node );
}
g_list_free( fragment->children );
/* Free attributes */
node = fragment->attributes;
2001-09-02 01:48:06 +02:00
while( node ) {
AddressIfAttrib *nv = node->data;
2003-06-21 08:23:00 +02:00
g_free( nv->name );
g_free( nv->value );
2001-09-02 01:48:06 +02:00
g_free( nv );
node->data = NULL;
node = g_list_next( node );
}
2003-06-21 08:23:00 +02:00
g_list_free( fragment->attributes );
g_free( fragment->name );
fragment->name = NULL;
fragment->attributes = NULL;
fragment->children = NULL;
g_free( fragment );
2001-09-02 01:48:06 +02:00
}
2003-06-21 08:23:00 +02:00
/**
* Create a new data source.
* \param ifType Interface type to create.
* \return Initialized data source.
*/
AddressDataSource *addrindex_create_datasource( AddressIfType ifType ) {
AddressDataSource *ds = g_new0( AddressDataSource, 1 );
2001-09-02 01:48:06 +02:00
ADDRITEM_TYPE(ds) = ITEMTYPE_DATASOURCE;
ADDRITEM_ID(ds) = NULL;
ADDRITEM_NAME(ds) = NULL;
ADDRITEM_PARENT(ds) = NULL;
ADDRITEM_SUBTYPE(ds) = 0;
ds->type = ifType;
2001-09-02 01:48:06 +02:00
ds->rawDataSource = NULL;
ds->interface = NULL;
return ds;
2001-09-02 01:48:06 +02:00
}
2003-06-21 08:23:00 +02:00
/**
* Free up data source.
* \param ds Data source to free.
*/
void addrindex_free_datasource( AddressDataSource *ds ) {
AddressInterface *iface;
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_if_fail( ds != NULL );
iface = ds->interface;
if( ds->rawDataSource != NULL ) {
2003-01-02 02:56:30 +01:00
if( iface != NULL ) {
if( iface->useInterface ) {
if( iface->type == ADDR_IF_BOOK ) {
AddressBookFile *abf = ds->rawDataSource;
addrbook_free_book( abf );
}
else if( iface->type == ADDR_IF_VCARD ) {
VCardFile *vcf = ds->rawDataSource;
vcard_free( vcf );
}
2001-09-02 01:48:06 +02:00
#ifdef USE_JPILOT
2003-01-02 02:56:30 +01:00
else if( iface->type == ADDR_IF_JPILOT ) {
JPilotFile *jpf = ds->rawDataSource;
jpilot_free( jpf );
}
2001-09-02 01:48:06 +02:00
#endif
#ifdef USE_LDAP
2003-01-02 02:56:30 +01:00
else if( iface->type == ADDR_IF_LDAP ) {
2003-06-21 08:23:00 +02:00
LdapServer *server = ds->rawDataSource;
ldapsvr_free( server );
2003-01-02 02:56:30 +01:00
}
2001-09-02 01:48:06 +02:00
#endif
2003-01-02 02:56:30 +01:00
else {
}
}
else {
2003-06-21 08:23:00 +02:00
AddressIfFragment *fragment = ds->rawDataSource;
addrindex_free_fragment( fragment );
2003-01-02 02:56:30 +01:00
}
2001-09-02 01:48:06 +02:00
}
}
2001-09-02 01:48:06 +02:00
ADDRITEM_TYPE(ds) = ITEMTYPE_NONE;
ADDRITEM_ID(ds) = NULL;
ADDRITEM_NAME(ds) = NULL;
ADDRITEM_PARENT(ds) = NULL;
ADDRITEM_SUBTYPE(ds) = 0;
ds->type = ADDR_IF_NONE;
ds->interface = NULL;
ds->rawDataSource = NULL;
2003-06-21 08:23:00 +02:00
g_free( ds );
}
2003-06-21 08:23:00 +02:00
/**
* Free up all data sources for specified interface.
* \param iface Address interface to process.
*/
static void addrindex_free_all_datasources( AddressInterface *iface ) {
GList *node = iface->listSource;
while( node ) {
AddressDataSource *ds = node->data;
addrindex_free_datasource( ds );
2001-09-02 01:48:06 +02:00
node->data = NULL;
node = g_list_next( node );
}
}
2003-06-21 08:23:00 +02:00
/**
* Free up specified interface.
* \param iface Interface to process.
*/
2001-09-06 12:24:20 +02:00
static void addrindex_free_interface( AddressInterface *iface ) {
2003-01-02 02:56:30 +01:00
/* Free up data sources */
2001-09-02 01:48:06 +02:00
addrindex_free_all_datasources( iface );
2003-01-02 02:56:30 +01:00
g_list_free( iface->listSource );
2001-09-02 01:48:06 +02:00
2003-01-02 02:56:30 +01:00
/* Free internal storage */
2001-09-02 01:48:06 +02:00
g_free( ADDRITEM_ID(iface) );
g_free( ADDRITEM_NAME(iface) );
g_free( iface->name );
g_free( iface->listTag );
g_free( iface->itemTag );
2003-01-02 02:56:30 +01:00
/* Clear all pointers */
2001-09-02 01:48:06 +02:00
ADDRITEM_TYPE(iface) = ITEMTYPE_NONE;
ADDRITEM_ID(iface) = NULL;
ADDRITEM_NAME(iface) = NULL;
ADDRITEM_PARENT(iface) = NULL;
ADDRITEM_SUBTYPE(iface) = 0;
iface->type = ADDR_IF_NONE;
iface->name = NULL;
iface->listTag = NULL;
iface->itemTag = NULL;
iface->legacyFlag = FALSE;
iface->useInterface = FALSE;
iface->haveLibrary = FALSE;
iface->listSource = NULL;
2003-01-02 02:56:30 +01:00
2003-06-21 08:23:00 +02:00
/* Search stuff */
iface->searchOrder = 0;
iface->startSearch = NULL;
iface->stopSearch = NULL;
2003-01-02 02:56:30 +01:00
g_free( iface );
2001-09-02 01:48:06 +02:00
}
2003-06-21 08:23:00 +02:00
/**
* Return cache ID for specified data source.
2003-06-21 08:23:00 +02:00
*
* \param addrIndex Address index.
* \param ds Data source.
* \return ID or NULL if not found. This should be <code>g_free()</code>
* when done.
*/
gchar *addrindex_get_cache_id( AddressIndex *addrIndex, AddressDataSource *ds ) {
gchar *cacheID = NULL;
AddrBookBase *adbase;
AddressCache *cache;
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, NULL );
cm_return_val_if_fail( ds != NULL, NULL );
adbase = ( AddrBookBase * ) ds->rawDataSource;
if( adbase ) {
cache = adbase->addressCache;
if( cache ) {
cacheID = g_strdup( cache->cacheID );
}
}
return cacheID;
}
2003-06-21 08:23:00 +02:00
/**
* Return reference to data source for specified cacheID.
* \param addrIndex Address index.
* \param cacheID ID.
* \return Data source, or NULL if not found.
*/
static AddressDataSource *addrindex_get_datasource(
2003-06-21 08:23:00 +02:00
AddressIndex *addrIndex, const gchar *cacheID )
{
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, NULL );
cm_return_val_if_fail( cacheID != NULL, NULL );
return ( AddressDataSource * ) g_hash_table_lookup( addrIndex->hashCache, cacheID );
}
2003-06-21 08:23:00 +02:00
/**
* Return reference to address cache for specified cacheID.
* \param addrIndex Address index.
* \param cacheID ID.
* \return Address cache, or NULL if not found.
*/
AddressCache *addrindex_get_cache( AddressIndex *addrIndex, const gchar *cacheID ) {
AddressDataSource *ds;
AddrBookBase *adbase;
AddressCache *cache;
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, NULL );
cm_return_val_if_fail( cacheID != NULL, NULL );
cache = NULL;
ds = addrindex_get_datasource( addrIndex, cacheID );
if( ds ) {
adbase = ( AddrBookBase * ) ds->rawDataSource;
cache = adbase->addressCache;
}
return cache;
}
2003-06-21 08:23:00 +02:00
/**
* Add data source into hash table.
* \param addrIndex Address index.
* \param ds Data source.
*/
2003-06-21 08:23:00 +02:00
static void addrindex_hash_add_cache(
AddressIndex *addrIndex, AddressDataSource *ds )
{
gchar *cacheID;
cacheID = addrindex_get_cache_id( addrIndex, ds );
if( cacheID ) {
g_hash_table_insert( addrIndex->hashCache, cacheID, ds );
}
}
/*
2003-06-21 08:23:00 +02:00
* Free hash table callback function.
*/
static gboolean addrindex_free_cache_cb( gpointer key, gpointer value, gpointer data ) {
g_free( key );
key = NULL;
value = NULL;
return TRUE;
}
/*
2003-06-21 08:23:00 +02:00
* Free hash table of address cache items.
*/
static void addrindex_free_cache_hash( GHashTable *table ) {
g_hash_table_foreach_remove( table, addrindex_free_cache_cb, NULL );
g_hash_table_destroy( table );
}
2004-01-12 22:28:31 +01:00
/**
2003-06-21 08:23:00 +02:00
* Remove data source from internal hashtable.
* \param addrIndex Address index.
* \param ds Data source to remove.
*/
static void addrindex_hash_remove_cache(
AddressIndex *addrIndex, AddressDataSource *ds )
{
gchar *cacheID;
cacheID = addrindex_get_cache_id( addrIndex, ds );
if( cacheID ) {
g_hash_table_remove( addrIndex->hashCache, cacheID );
g_free( cacheID );
cacheID = NULL;
}
}
2004-01-12 22:28:31 +01:00
/**
* Create a new address index. This is created as a singleton object.
2003-06-21 08:23:00 +02:00
* \return Initialized address index object.
*/
AddressIndex *addrindex_create_index( void ) {
2004-01-12 22:28:31 +01:00
AddressIndex *index;
if( _addressIndex_ == NULL ) {
index = g_new0( AddressIndex, 1 );
ADDRITEM_TYPE(index) = ITEMTYPE_INDEX;
ADDRITEM_ID(index) = NULL;
ADDRITEM_NAME(index) = g_strdup( "Address Index" );
ADDRITEM_PARENT(index) = NULL;
ADDRITEM_SUBTYPE(index) = 0;
index->filePath = NULL;
index->fileName = NULL;
index->retVal = MGU_SUCCESS;
index->needsConversion = FALSE;
index->wasConverted = FALSE;
index->conversionError = FALSE;
index->interfaceList = NULL;
index->lastType = ADDR_IF_NONE;
index->dirtyFlag = FALSE;
index->hashCache = g_hash_table_new( g_str_hash, g_str_equal );
index->loadedFlag = FALSE;
index->searchOrder = NULL;
addrindex_build_if_list( index );
_addressIndex_ = index;
}
return _addressIndex_;
}
2001-09-06 12:24:20 +02:00
2003-06-21 08:23:00 +02:00
/**
* Property - Specify file path to address index file.
* \param addrIndex Address index.
* \param value Path to index file.
*/
2001-09-02 01:48:06 +02:00
void addrindex_set_file_path( AddressIndex *addrIndex, const gchar *value ) {
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_if_fail( addrIndex != NULL );
2001-09-02 01:48:06 +02:00
addrIndex->filePath = mgu_replace_string( addrIndex->filePath, value );
}
2003-06-21 08:23:00 +02:00
/**
* Property - Specify file name to address index file.
* \param addrIndex Address index.
* \param value File name.
*/
2001-09-02 01:48:06 +02:00
void addrindex_set_file_name( AddressIndex *addrIndex, const gchar *value ) {
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_if_fail( addrIndex != NULL );
2001-09-02 01:48:06 +02:00
addrIndex->fileName = mgu_replace_string( addrIndex->fileName, value );
}
2003-06-21 08:23:00 +02:00
/**
* Return list of address interfaces.
* \param addrIndex Address index.
* \return List of address interfaces.
*/
2001-09-02 01:48:06 +02:00
GList *addrindex_get_interface_list( AddressIndex *addrIndex ) {
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, NULL );
2001-09-02 01:48:06 +02:00
return addrIndex->interfaceList;
}
2003-06-21 08:23:00 +02:00
/**
* Perform any other initialization of address index.
*/
2004-01-12 22:28:31 +01:00
void addrindex_initialize( void ) {
2003-09-07 21:28:56 +02:00
qrymgr_initialize();
2004-01-12 22:28:31 +01:00
addrcompl_initialize();
2003-06-21 08:23:00 +02:00
}
/**
* Perform any other teardown of address index.
*/
2004-01-12 22:28:31 +01:00
void addrindex_teardown( void ) {
2003-06-21 08:23:00 +02:00
addrcompl_teardown();
2003-09-07 21:28:56 +02:00
qrymgr_teardown();
2003-06-21 08:23:00 +02:00
}
/**
* Free up address index.
* \param addrIndex Address index.
*/
2001-09-02 01:48:06 +02:00
void addrindex_free_index( AddressIndex *addrIndex ) {
GList *node;
2001-09-06 12:24:20 +02:00
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_if_fail( addrIndex != NULL );
2001-09-02 01:48:06 +02:00
2003-06-21 08:23:00 +02:00
/* Search stuff */
g_list_free( addrIndex->searchOrder );
addrIndex->searchOrder = NULL;
/* Free internal storage */
2001-09-02 01:48:06 +02:00
g_free( ADDRITEM_ID(addrIndex) );
g_free( ADDRITEM_NAME(addrIndex) );
g_free( addrIndex->filePath );
g_free( addrIndex->fileName );
2003-06-21 08:23:00 +02:00
/* Clear pointers */
2001-09-02 01:48:06 +02:00
ADDRITEM_TYPE(addrIndex) = ITEMTYPE_NONE;
ADDRITEM_ID(addrIndex) = NULL;
ADDRITEM_NAME(addrIndex) = NULL;
ADDRITEM_PARENT(addrIndex) = NULL;
ADDRITEM_SUBTYPE(addrIndex) = 0;
addrIndex->filePath = NULL;
addrIndex->fileName = NULL;
addrIndex->retVal = MGU_SUCCESS;
addrIndex->needsConversion = FALSE;
addrIndex->wasConverted = FALSE;
addrIndex->conversionError = FALSE;
addrIndex->lastType = ADDR_IF_NONE;
addrIndex->dirtyFlag = FALSE;
2003-06-21 08:23:00 +02:00
/* Free up interfaces */
2001-09-02 01:48:06 +02:00
node = addrIndex->interfaceList;
while( node ) {
AddressInterface *iface = node->data;
addrindex_free_interface( iface );
node = g_list_next( node );
}
g_list_free( addrIndex->interfaceList );
addrIndex->interfaceList = NULL;
2003-06-21 08:23:00 +02:00
/* Free up hash cache */
addrindex_free_cache_hash( addrIndex->hashCache );
addrIndex->hashCache = NULL;
2003-06-21 08:23:00 +02:00
addrIndex->loadedFlag = FALSE;
2001-09-02 01:48:06 +02:00
g_free( addrIndex );
2004-01-12 22:28:31 +01:00
addrIndex = NULL;
_addressIndex_ = NULL;
2001-09-02 01:48:06 +02:00
}
2003-06-21 08:23:00 +02:00
/**
* Print address index.
* \param addrIndex Address index.
* \parem stream Stream to print.
2001-09-02 01:48:06 +02:00
*/
void addrindex_print_index( AddressIndex *addrIndex, FILE *stream ) {
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_if_fail( addrIndex != NULL );
2001-09-02 01:48:06 +02:00
fprintf( stream, "AddressIndex:\n" );
fprintf( stream, "\tfile path: '%s'\n", addrIndex->filePath );
fprintf( stream, "\tfile name: '%s'\n", addrIndex->fileName );
2003-06-21 08:23:00 +02:00
fprintf( stream, "\t status: %d\n", addrIndex->retVal );
fprintf( stream, "\tconverted: '%s'\n",
addrIndex->wasConverted ? "yes" : "no" );
fprintf( stream, "\tcvt error: '%s'\n",
addrIndex->conversionError ? "yes" : "no" );
2001-09-02 01:48:06 +02:00
fprintf( stream, "\t---\n" );
}
2003-06-21 08:23:00 +02:00
/**
* Retrieve reference to address interface for specified interface type.
* \param addrIndex Address index.
* \param ifType Interface type.
* \return Address interface, or NULL if not found.
*/
static AddressInterface *addrindex_get_interface(
AddressIndex *addrIndex, AddressIfType ifType )
{
2001-09-02 01:48:06 +02:00
AddressInterface *retVal = NULL;
GList *node;
2001-09-06 12:24:20 +02:00
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, NULL );
2001-09-06 12:24:20 +02:00
2001-09-02 01:48:06 +02:00
node = addrIndex->interfaceList;
while( node ) {
AddressInterface *iface = node->data;
node = g_list_next( node );
if( iface->type == ifType ) {
retVal = iface;
break;
}
}
return retVal;
}
2003-06-21 08:23:00 +02:00
/**
* Add raw data source to index. The raw data object (an AddressBookFile or
* VCardFile object, for example) should be supplied as the raw dataSource
* argument.
*
* \param addrIndex Address index.
* \param ifType Interface type to add.
* \param dataSource Actual raw data source to add.
* \return Data source added, or NULL if invalid interface type.
*/
AddressDataSource *addrindex_index_add_datasource(
AddressIndex *addrIndex, AddressIfType ifType, gpointer dataSource )
{
2001-09-02 01:48:06 +02:00
AddressInterface *iface;
AddressDataSource *ds = NULL;
2001-09-06 12:24:20 +02:00
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, NULL );
cm_return_val_if_fail( dataSource != NULL, NULL );
2001-09-02 01:48:06 +02:00
iface = addrindex_get_interface( addrIndex, ifType );
if( iface ) {
ds = addrindex_create_datasource( ifType );
2001-09-02 01:48:06 +02:00
ADDRITEM_PARENT(ds) = ADDRITEM_OBJECT(iface);
ds->type = ifType;
ds->rawDataSource = dataSource;
ds->interface = iface;
iface->listSource = g_list_append( iface->listSource, ds );
addrIndex->dirtyFlag = TRUE;
addrindex_hash_add_cache( addrIndex, ds );
2001-09-02 01:48:06 +02:00
}
return ds;
}
2003-06-21 08:23:00 +02:00
/**
* Remove specified data source from index.
* \param addrIndex Address index.
* \param dataSource Data source to add.
* \return Reference to data source if removed, or NULL if data source was not
* found in index. Note the this object must still be freed.
*/
AddressDataSource *addrindex_index_remove_datasource(
AddressIndex *addrIndex, AddressDataSource *dataSource )
{
2001-09-02 01:48:06 +02:00
AddressDataSource *retVal = FALSE;
AddressInterface *iface;
2001-09-06 12:24:20 +02:00
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, NULL );
cm_return_val_if_fail( dataSource != NULL, NULL );
2001-09-02 01:48:06 +02:00
iface = addrindex_get_interface( addrIndex, dataSource->type );
if( iface ) {
iface->listSource = g_list_remove( iface->listSource, dataSource );
addrIndex->dirtyFlag = TRUE;
dataSource->interface = NULL;
/* Remove cache from hash table */
addrindex_hash_remove_cache( addrIndex, dataSource );
2001-09-02 01:48:06 +02:00
retVal = dataSource;
}
return retVal;
}
2003-06-21 08:23:00 +02:00
/**
* Retrieve a reference to address interface for specified interface type and
* XML interface tag name.
* \param addrIndex Address index.
* \param tag XML interface tag name to match.
* \param ifType Interface type to match.
* \return Reference to address index, or NULL if not found in index.
*/
static AddressInterface *addrindex_tag_get_interface(
AddressIndex *addrIndex, gchar *tag, AddressIfType ifType )
{
2001-09-02 01:48:06 +02:00
AddressInterface *retVal = NULL;
GList *node = addrIndex->interfaceList;
2001-09-06 12:24:20 +02:00
2001-09-02 01:48:06 +02:00
while( node ) {
AddressInterface *iface = node->data;
node = g_list_next( node );
if( tag ) {
if( strcmp( iface->listTag, tag ) == 0 ) {
retVal = iface;
break;
}
}
else {
if( iface->type == ifType ) {
retVal = iface;
break;
}
}
}
return retVal;
}
2003-06-21 08:23:00 +02:00
/**
* Retrieve a reference to address interface for specified interface type and
* XML datasource tag name.
* \param addrIndex Address index.
* \param ifType Interface type to match.
* \param tag XML datasource tag name to match.
* \return Reference to address index, or NULL if not found in index.
*/
static AddressInterface *addrindex_tag_get_datasource(
AddressIndex *addrIndex, AddressIfType ifType, gchar *tag )
{
2001-09-02 01:48:06 +02:00
AddressInterface *retVal = NULL;
GList *node = addrIndex->interfaceList;
2001-09-06 12:24:20 +02:00
2001-09-02 01:48:06 +02:00
while( node ) {
AddressInterface *iface = node->data;
node = g_list_next( node );
if( iface->type == ifType && iface->itemTag ) {
if( strcmp( iface->itemTag, tag ) == 0 ) {
retVal = iface;
break;
}
}
}
return retVal;
}
/* **********************************************************************
* Interface XML parsing functions.
* ***********************************************************************
*/
2003-06-21 08:23:00 +02:00
/**
* Write start of XML element to file.
* \param fp File.
* \param lvl Indentation level.
* \param name Element name.
*/
static int addrindex_write_elem_s( FILE *fp, const gint lvl, const gchar *name ) {
2001-09-02 01:48:06 +02:00
gint i;
for( i = 0; i < lvl; i++ )
if (fputs( " ", fp ) == EOF)
return -1;
if (fputs( "<", fp ) == EOF)
return -1;
if (fputs( name, fp ) == EOF)
return -1;
return 0;
2001-09-02 01:48:06 +02:00
}
2003-06-21 08:23:00 +02:00
/**
* Write end of XML element to file.
* \param fp File.
* \param lvl Indentation level.
* \param name Element name.
*/
static int addrindex_write_elem_e( FILE *fp, const gint lvl, const gchar *name ) {
2001-09-02 01:48:06 +02:00
gint i;
for( i = 0; i < lvl; i++ )
if (fputs( " ", fp ) == EOF)
return -1;
if (fputs( "</", fp ) == EOF)
return -1;
if (fputs( name, fp ) == EOF)
return -1;
if (fputs( ">\n", fp ) == EOF)
return -1;
return 0;
2001-09-02 01:48:06 +02:00
}
2003-06-21 08:23:00 +02:00
/**
* Write XML attribute to file.
* \param fp File.
* \param name Attribute name.
* \param value Attribute value.
*/
static int addrindex_write_attr( FILE *fp, const gchar *name, const gchar *value ) {
if (fputs( " ", fp ) == EOF)
return -1;
if (fputs( name, fp ) == EOF)
return -1;
if (fputs( "=\"", fp ) == EOF)
return -1;
if (xml_file_put_escape_str( fp, value ) < 0)
return -1;
if (fputs( "\"", fp ) == EOF)
return -1;
return 0;
2001-09-02 01:48:06 +02:00
}
#if !defined(USE_LDAP) || !defined(USE_JPILOT)
/**
* Return DOM fragment for current XML tag from file.
* \param file XML file being processed.
* \return Fragment representing DOM fragment for configuration element.
*/
static AddressIfFragment *addrindex_read_fragment( XMLFile *file ) {
AddressIfFragment *fragment;
AddressIfFragment *child;
AddressIfAttrib *nv;
XMLTag *xtag;
GList *list;
GList *attr;
gchar *name;
gchar *value;
guint prevLevel;
gint rc;
/* g_print( "addrindex_read_fragment\n" ); */
prevLevel = file->level;
/* Get current tag name */
xtag = xml_get_current_tag( file );
/* Create new fragment */
fragment = g_new0( AddressIfFragment, 1 );
fragment->name = g_strdup( xtag->tag );
fragment->children = NULL;
fragment->attributes = NULL;
/* Read attributes */
list = NULL;
attr = xml_get_current_tag_attr( file );
while( attr ) {
name = ((XMLAttr *)attr->data)->name;
value = ((XMLAttr *)attr->data)->value;
nv = g_new0( AddressIfAttrib, 1 );
nv->name = g_strdup( name );
nv->value = g_strdup( value );
list = g_list_append( list, nv );
attr = g_list_next( attr );
}
fragment->attributes = list;
/* Now read the children */
while( TRUE ) {
rc = xml_parse_next_tag( file );
if( rc != 0 ) {
/* End of file? */
break;
}
if( file->level < prevLevel ) {
/* We must be above level we start at */
break;
}
child = addrindex_read_fragment( file );
fragment->children = g_list_append( fragment->children, child );
}
return fragment;
}
/**
* Write DOM fragment to file.
* \param fp File to write.
* \param fragment DOM fragment for configuration element.
* \param lvl Indent level.
*/
static int addrindex_write_fragment(
FILE *fp, const AddressIfFragment *fragment, const gint lvl )
{
GList *node;
if( fragment ) {
if (addrindex_write_elem_s( fp, lvl, fragment->name ) < 0)
return -1;
node = fragment->attributes;
while( node ) {
AddressIfAttrib *nv = node->data;
if (addrindex_write_attr( fp, nv->name, nv->value ) < 0)
return -1;
node = g_list_next( node );
}
if( fragment->children ) {
if (fputs(" >\n", fp) == EOF)
return -1;
/* Output children */
node = fragment->children;
while( node ) {
AddressIfFragment *child = node->data;
if (addrindex_write_fragment( fp, child, 1+lvl ) < 0)
return -1;
node = g_list_next( node );
}
/* Output closing tag */
if (addrindex_write_elem_e( fp, lvl, fragment->name ) < 0)
return -1;
}
else {
if (fputs(" />\n", fp) == EOF)
return -1;
}
}
return 0;
}
#endif
2003-06-21 08:23:00 +02:00
/**
* Read/parse address index file, creating a data source for a regular
* intrinsic XML addressbook.
* \param file Address index file.
* \return Data source.
*/
2001-09-02 01:48:06 +02:00
static AddressDataSource *addrindex_parse_book( XMLFile *file ) {
AddressDataSource *ds;
2001-09-02 01:48:06 +02:00
AddressBookFile *abf;
GList *attr;
ds = addrindex_create_datasource( ADDR_IF_BOOK );
2001-09-02 01:48:06 +02:00
abf = addrbook_create_book();
attr = xml_get_current_tag_attr( file );
while( attr ) {
gchar *name = ((XMLAttr *)attr->data)->name;
gchar *value = ((XMLAttr *)attr->data)->value;
if( strcmp( name, ATTAG_BOOK_NAME ) == 0 ) {
addrbook_set_name( abf, value );
}
else if( strcmp( name, ATTAG_BOOK_FILE ) == 0) {
addrbook_set_file( abf, value );
}
attr = g_list_next( attr );
}
ds->rawDataSource = abf;
return ds;
}
static int addrindex_write_book( FILE *fp, AddressDataSource *ds, gint lvl ) {
2001-09-02 01:48:06 +02:00
AddressBookFile *abf = ds->rawDataSource;
if( abf ) {
if (addrindex_write_elem_s( fp, lvl, TAG_DS_ADDRESS_BOOK ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_BOOK_NAME, addrbook_get_name( abf ) ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_BOOK_FILE, abf->fileName ) < 0)
return -1;
if (fputs( " />\n", fp ) == EOF)
return -1;
2001-09-02 01:48:06 +02:00
}
return 0;
2001-09-02 01:48:06 +02:00
}
static AddressDataSource *addrindex_parse_vcard( XMLFile *file ) {
AddressDataSource *ds;
2001-09-02 01:48:06 +02:00
VCardFile *vcf;
GList *attr;
ds = addrindex_create_datasource( ADDR_IF_VCARD );
2001-09-02 01:48:06 +02:00
vcf = vcard_create();
attr = xml_get_current_tag_attr( file );
while( attr ) {
gchar *name = ((XMLAttr *)attr->data)->name;
gchar *value = ((XMLAttr *)attr->data)->value;
if( strcmp( name, ATTAG_VCARD_NAME ) == 0 ) {
vcard_set_name( vcf, value );
}
else if( strcmp( name, ATTAG_VCARD_FILE ) == 0) {
vcard_set_file( vcf, value );
}
attr = g_list_next( attr );
}
ds->rawDataSource = vcf;
return ds;
}
static int addrindex_write_vcard( FILE *fp, AddressDataSource *ds, gint lvl ) {
2001-09-02 01:48:06 +02:00
VCardFile *vcf = ds->rawDataSource;
if( vcf ) {
if (addrindex_write_elem_s( fp, lvl, TAG_DS_VCARD ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_VCARD_NAME, vcard_get_name( vcf ) ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_VCARD_FILE, vcf->path ) < 0)
return -1;
if (fputs( " />\n", fp ) == EOF)
return -1;
2001-09-02 01:48:06 +02:00
}
return 0;
2001-09-02 01:48:06 +02:00
}
#ifdef USE_JPILOT
static AddressDataSource *addrindex_parse_jpilot( XMLFile *file ) {
AddressDataSource *ds;
2001-09-02 01:48:06 +02:00
JPilotFile *jpf;
GList *attr;
ds = addrindex_create_datasource( ADDR_IF_JPILOT );
2001-09-02 01:48:06 +02:00
jpf = jpilot_create();
attr = xml_get_current_tag_attr( file );
while( attr ) {
gchar *name = ((XMLAttr *)attr->data)->name;
gchar *value = ((XMLAttr *)attr->data)->value;
if( strcmp( name, ATTAG_JPILOT_NAME ) == 0 ) {
jpilot_set_name( jpf, value );
}
else if( strcmp( name, ATTAG_JPILOT_FILE ) == 0 ) {
jpilot_set_file( jpf, value );
}
else if( strcmp( name, ATTAG_JPILOT_CUSTOM_1 ) == 0 ) {
jpilot_add_custom_label( jpf, value );
}
else if( strcmp( name, ATTAG_JPILOT_CUSTOM_2 ) == 0 ) {
jpilot_add_custom_label( jpf, value );
}
else if( strcmp( name, ATTAG_JPILOT_CUSTOM_3 ) == 0 ) {
jpilot_add_custom_label( jpf, value );
}
else if( strcmp( name, ATTAG_JPILOT_CUSTOM_4 ) == 0 ) {
jpilot_add_custom_label( jpf, value );
}
attr = g_list_next( attr );
}
ds->rawDataSource = jpf;
return ds;
}
static int addrindex_write_jpilot( FILE *fp,AddressDataSource *ds, gint lvl ) {
2001-09-02 01:48:06 +02:00
JPilotFile *jpf = ds->rawDataSource;
if( jpf ) {
gint ind;
GList *node;
GList *customLbl = jpilot_get_custom_labels( jpf );
if (addrindex_write_elem_s( fp, lvl, TAG_DS_JPILOT ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_JPILOT_NAME, jpilot_get_name( jpf ) ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_JPILOT_FILE, jpf->path ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
node = customLbl;
ind = 1;
while( node ) {
gchar name[256];
g_snprintf( name, sizeof(name), "%s%d",
ATTAG_JPILOT_CUSTOM, ind );
if (addrindex_write_attr( fp, name, node->data ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
ind++;
node = g_list_next( node );
}
if (fputs( " />\n", fp ) == EOF)
return -1;
2001-09-02 01:48:06 +02:00
}
return 0;
2001-09-02 01:48:06 +02:00
}
2003-06-21 08:23:00 +02:00
#else
2003-06-21 08:23:00 +02:00
/*
* Just read/write DOM fragments (preserve data found in file).
*/
static AddressDataSource *addrindex_parse_jpilot( XMLFile *file ) {
AddressDataSource *ds;
2003-03-17 07:49:25 +01:00
ds = addrindex_create_datasource( ADDR_IF_JPILOT );
2003-06-21 08:23:00 +02:00
ds->rawDataSource = addrindex_read_fragment( file );
return ds;
}
2003-03-17 07:49:25 +01:00
static int addrindex_write_jpilot( FILE *fp, AddressDataSource *ds, gint lvl ) {
2003-06-21 08:23:00 +02:00
AddressIfFragment *fragment = ds->rawDataSource;
if( fragment ) {
if (addrindex_write_fragment( fp, fragment, lvl ) < 0)
return -1;
2003-03-17 07:49:25 +01:00
}
return 0;
2003-03-17 07:49:25 +01:00
}
#endif
2003-03-17 07:49:25 +01:00
#ifdef USE_LDAP
2003-06-21 08:23:00 +02:00
/**
* Parse LDAP criteria attribute data from XML file.
* \param file Index file.
* \param ctl LDAP control object to populate.
*/
static void addrindex_parse_ldap_attrlist( XMLFile *file, LdapControl *ctl ) {
guint prevLevel;
XMLTag *xtag;
XMLTag *xtagPrev;
gint rc;
GList *attr;
GList *list;
GList *node;
if( file == NULL ) {
return;
}
list = NULL;
prevLevel = file->level;
xtagPrev = xml_get_current_tag( file );
while( TRUE ) {
rc = xml_parse_next_tag( file );
if( rc != 0 ) {
/* Terminate prematurely */
mgu_free_dlist( list );
list = NULL;
return;
}
if( file->level < prevLevel ) {
/* We must be above level we start at */
break;
}
/* Get a tag (element) */
xtag = xml_get_current_tag( file );
if( strcmp( xtag->tag, ELTAG_LDAP_ATTR_SRCH ) == 0 ) {
/* LDAP criteria attribute */
attr = xml_get_current_tag_attr( file );
while( attr ) {
gchar *name = ((XMLAttr *)attr->data)->name;
gchar *value = ((XMLAttr *)attr->data)->value;
if( strcmp( name, ATTAG_LDAP_ATTR_NAME ) == 0 ) {
if( value && strlen( value ) > 0 ) {
list = g_list_append(
list, g_strdup( value ) );
}
}
attr = g_list_next( attr );
}
}
else {
if( xtag != xtagPrev ) {
/* Found a new tag */
break;
}
}
xtag = xtagPrev;
}
/* Build list of search attributes */
ldapctl_criteria_list_clear( ctl );
node = list;
while( node ) {
ldapctl_criteria_list_add( ctl, node->data );
g_free( node->data );
node->data = NULL;
node = g_list_next( node );
}
g_list_free( list );
list = NULL;
}
void ldapsvr_set_control( LdapServer *server, LdapControl *ctl );
2004-01-12 22:28:31 +01:00
/**
* Parse LDAP control data from XML file.
* \param file Index file.
* \return Initialized data soruce object.
*/
2001-09-02 01:48:06 +02:00
static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) {
AddressDataSource *ds;
2003-06-21 08:23:00 +02:00
LdapServer *server;
LdapControl *ctl;
2001-09-02 01:48:06 +02:00
GList *attr;
2003-06-21 08:23:00 +02:00
gchar *serverName = NULL;
gchar *criteria = NULL;
2004-01-12 22:28:31 +01:00
gboolean bDynSearch;
gboolean bTLS, bSSL;
2004-01-12 22:28:31 +01:00
gint iMatch;
2003-06-21 08:23:00 +02:00
/* g_print( "addrindex_parse_ldap\n" ); */
2004-01-12 22:28:31 +01:00
/* Set up some defaults */
bDynSearch = FALSE;
2004-05-10 12:22:28 +02:00
bTLS = FALSE;
bSSL = FALSE;
2004-01-12 22:28:31 +01:00
iMatch = LDAPCTL_MATCH_BEGINWITH;
2001-09-02 01:48:06 +02:00
ds = addrindex_create_datasource( ADDR_IF_LDAP );
2003-06-21 08:23:00 +02:00
ctl = ldapctl_create();
2001-09-02 01:48:06 +02:00
attr = xml_get_current_tag_attr( file );
while( attr ) {
gchar *name = ((XMLAttr *)attr->data)->name;
gchar *value = ((XMLAttr *)attr->data)->value;
gint ivalue = atoi( value );
2003-06-21 08:23:00 +02:00
2001-09-02 01:48:06 +02:00
if( strcmp( name, ATTAG_LDAP_NAME ) == 0 ) {
g_free( serverName );
2003-06-21 08:23:00 +02:00
serverName = g_strdup( value );
2001-09-02 01:48:06 +02:00
}
else if( strcmp( name, ATTAG_LDAP_HOST ) == 0 ) {
2003-06-21 08:23:00 +02:00
ldapctl_set_host( ctl, value );
2001-09-02 01:48:06 +02:00
}
else if( strcmp( name, ATTAG_LDAP_PORT ) == 0 ) {
2003-06-21 08:23:00 +02:00
ldapctl_set_port( ctl, ivalue );
2001-09-02 01:48:06 +02:00
}
else if( strcmp( name, ATTAG_LDAP_BASE_DN ) == 0 ) {
2003-06-21 08:23:00 +02:00
ldapctl_set_base_dn( ctl, value );
2001-09-02 01:48:06 +02:00
}
else if( strcmp( name, ATTAG_LDAP_BIND_DN ) == 0 ) {
2003-06-21 08:23:00 +02:00
ldapctl_set_bind_dn( ctl, value );
2001-09-02 01:48:06 +02:00
}
else if( strcmp( name, ATTAG_LDAP_BIND_PASS ) == 0 ) {
ldapctl_set_bind_password( ctl, value, FALSE, FALSE );
2001-09-02 01:48:06 +02:00
}
else if( strcmp( name, ATTAG_LDAP_CRITERIA ) == 0 ) {
g_free( criteria );
2003-06-21 08:23:00 +02:00
criteria = g_strdup( value );
g_print("criteria %s\n", criteria);
2001-09-02 01:48:06 +02:00
}
else if( strcmp( name, ATTAG_LDAP_MAX_ENTRY ) == 0 ) {
2003-06-21 08:23:00 +02:00
ldapctl_set_max_entries( ctl, ivalue );
2001-09-02 01:48:06 +02:00
}
else if( strcmp( name, ATTAG_LDAP_TIMEOUT ) == 0 ) {
2003-06-21 08:23:00 +02:00
ldapctl_set_timeout( ctl, ivalue );
}
else if( strcmp( name, ATTAG_LDAP_MAX_AGE ) == 0 ) {
ldapctl_set_max_query_age( ctl, ivalue );
}
else if( strcmp( name, ATTAG_LDAP_DYN_SEARCH ) == 0 ) {
2004-01-12 22:28:31 +01:00
bDynSearch = FALSE;
if( strcmp( value, ATVAL_BOOLEAN_YES ) == 0 ) {
bDynSearch = TRUE;
}
}
else if( strcmp( name, ATTAG_LDAP_MATCH_OPT ) == 0 ) {
iMatch = LDAPCTL_MATCH_BEGINWITH;
if( strcmp( value, ATVAL_LDAP_MATCH_CONTAINS ) == 0 ) {
iMatch = LDAPCTL_MATCH_CONTAINS;
2003-06-21 08:23:00 +02:00
}
2001-09-02 01:48:06 +02:00
}
2004-05-10 12:22:28 +02:00
else if( strcmp( name, ATTAG_LDAP_ENABLE_TLS ) == 0 ) {
bTLS = FALSE;
if( strcmp( value, ATVAL_BOOLEAN_YES ) == 0 ) {
bTLS = TRUE;
}
}
else if( strcmp( name, ATTAG_LDAP_ENABLE_SSL ) == 0 ) {
bSSL = FALSE;
if( strcmp( value, ATVAL_BOOLEAN_YES ) == 0 ) {
bSSL = TRUE;
}
}
2001-09-02 01:48:06 +02:00
attr = g_list_next( attr );
}
2003-06-21 08:23:00 +02:00
server = ldapsvr_create_noctl();
ldapsvr_set_name( server, serverName );
2004-01-12 22:28:31 +01:00
ldapsvr_set_search_flag( server, bDynSearch );
ldapctl_set_matching_option( ctl, iMatch );
2004-05-10 12:22:28 +02:00
ldapctl_set_tls( ctl, bTLS );
ldapctl_set_ssl( ctl, bSSL );
2003-06-21 08:23:00 +02:00
g_free( serverName );
ldapsvr_set_control( server, ctl );
2001-09-02 01:48:06 +02:00
ds->rawDataSource = server;
2003-06-21 08:23:00 +02:00
addrindex_parse_ldap_attrlist( file, ctl );
/*
* If criteria have been specified and no attributes were listed, then
* convert old style criteria into an attribute list. Any criteria will
* be dropped when saving data.
*/
if( criteria ) {
if( ! ldapctl_get_criteria_list( ctl ) ) {
ldapctl_parse_ldap_search( ctl, criteria );
}
g_free( criteria );
}
/* ldapsvr_print_data( server, stdout ); */
2001-09-02 01:48:06 +02:00
return ds;
}
static int addrindex_write_ldap( FILE *fp, AddressDataSource *ds, gint lvl ) {
2003-06-21 08:23:00 +02:00
LdapServer *server = ds->rawDataSource;
LdapControl *ctl = NULL;
GList *node;
gchar value[256];
2001-09-02 01:48:06 +02:00
if( server ) {
2003-06-21 08:23:00 +02:00
ctl = server->control;
}
if( ctl == NULL ) return 0;
2003-06-21 08:23:00 +02:00
/* Output start element with attributes */
if (addrindex_write_elem_s( fp, lvl, TAG_DS_LDAP ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_LDAP_NAME, ldapsvr_get_name( server ) ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_LDAP_HOST, ctl->hostName ) < 0)
return -1;
2003-03-17 07:49:25 +01:00
2003-06-21 08:23:00 +02:00
sprintf( value, "%d", ctl->port );
if (addrindex_write_attr( fp, ATTAG_LDAP_PORT, value ) < 0)
return -1;
2003-03-17 07:49:25 +01:00
if (addrindex_write_attr( fp, ATTAG_LDAP_BASE_DN, ctl->baseDN ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_LDAP_BIND_DN, ctl->bindDN ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_LDAP_BIND_PASS, ctl->bindPass ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
2003-06-21 08:23:00 +02:00
sprintf( value, "%d", ctl->maxEntries );
if (addrindex_write_attr( fp, ATTAG_LDAP_MAX_ENTRY, value ) < 0)
return -1;
2003-06-21 08:23:00 +02:00
sprintf( value, "%d", ctl->timeOut );
if (addrindex_write_attr( fp, ATTAG_LDAP_TIMEOUT, value ) < 0)
return -1;
2003-06-21 08:23:00 +02:00
sprintf( value, "%d", ctl->maxQueryAge );
if (addrindex_write_attr( fp, ATTAG_LDAP_MAX_AGE, value ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
if (addrindex_write_attr( fp, ATTAG_LDAP_DYN_SEARCH,
2004-01-12 22:28:31 +01:00
server->searchFlag ?
ATVAL_BOOLEAN_YES : ATVAL_BOOLEAN_NO ) < 0)
return -1;
2004-01-12 22:28:31 +01:00
if (addrindex_write_attr( fp, ATTAG_LDAP_MATCH_OPT,
2004-01-12 22:28:31 +01:00
( ctl->matchingOption == LDAPCTL_MATCH_CONTAINS ) ?
ATVAL_LDAP_MATCH_CONTAINS : ATVAL_LDAP_MATCH_BEGIN ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
if (addrindex_write_attr( fp, ATTAG_LDAP_ENABLE_TLS,
2004-05-10 12:22:28 +02:00
ctl->enableTLS ?
ATVAL_BOOLEAN_YES : ATVAL_BOOLEAN_NO ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_LDAP_ENABLE_SSL,
ctl->enableSSL ?
ATVAL_BOOLEAN_YES : ATVAL_BOOLEAN_NO ) < 0)
return -1;
2004-05-10 12:22:28 +02:00
if (fputs(" >\n", fp) == EOF)
return -1;
2003-06-21 08:23:00 +02:00
/* Output attributes */
node = ldapctl_get_criteria_list( ctl );
while( node ) {
if (addrindex_write_elem_s( fp, 1+lvl, ELTAG_LDAP_ATTR_SRCH ) < 0)
return -1;
if (addrindex_write_attr( fp, ATTAG_LDAP_ATTR_NAME, node->data ) < 0)
return -1;
if (fputs(" />\n", fp) == EOF)
return -1;
2003-06-21 08:23:00 +02:00
node = g_list_next( node );
2001-09-02 01:48:06 +02:00
}
2003-06-21 08:23:00 +02:00
/* End of element */
if (addrindex_write_elem_e( fp, lvl, TAG_DS_LDAP ) < 0)
return -1;
return 0;
}
2003-06-21 08:23:00 +02:00
#else
2003-06-21 08:23:00 +02:00
/*
* Just read/write DOM fragments (preserve data found in file).
*/
static AddressDataSource *addrindex_parse_ldap( XMLFile *file ) {
AddressDataSource *ds;
2003-03-17 07:49:25 +01:00
ds = addrindex_create_datasource( ADDR_IF_LDAP );
2003-06-21 08:23:00 +02:00
ds->rawDataSource = addrindex_read_fragment( file );
return ds;
}
2003-03-17 07:49:25 +01:00
static int addrindex_write_ldap( FILE *fp, AddressDataSource *ds, gint lvl ) {
2003-06-21 08:23:00 +02:00
AddressIfFragment *fragment = ds->rawDataSource;
if( fragment ) {
if (addrindex_write_fragment( fp, fragment, lvl ) < 0)
return -1;
}
return 0;
2001-09-02 01:48:06 +02:00
}
#endif
/* **********************************************************************
* Address index I/O functions.
* ***********************************************************************
*/
2003-06-21 08:23:00 +02:00
/**
* Read address index file, creating appropriate data sources for each address
* index file entry.
*
* \param addrIndex Address index.
* \param file Address index file.
*/
2001-09-02 01:48:06 +02:00
static void addrindex_read_index( AddressIndex *addrIndex, XMLFile *file ) {
guint prev_level;
XMLTag *xtag;
AddressInterface *iface = NULL, *dsIFace = NULL;
AddressDataSource *ds;
2003-06-21 08:23:00 +02:00
gint rc;
2001-09-02 01:48:06 +02:00
2003-06-21 08:23:00 +02:00
addrIndex->loadedFlag = FALSE;
2001-09-02 01:48:06 +02:00
for (;;) {
prev_level = file->level;
2003-06-21 08:23:00 +02:00
rc = xml_parse_next_tag( file );
if( file->level == 0 ) return;
2001-09-02 01:48:06 +02:00
xtag = xml_get_current_tag( file );
iface = addrindex_tag_get_interface( addrIndex, xtag->tag, ADDR_IF_NONE );
if( iface ) {
addrIndex->lastType = iface->type;
if( iface->legacyFlag ) addrIndex->needsConversion = TRUE;
}
else {
dsIFace = addrindex_tag_get_datasource(
addrIndex, addrIndex->lastType, xtag->tag );
2001-09-02 01:48:06 +02:00
if( dsIFace ) {
2001-09-30 13:07:34 +02:00
/* Add data source to list */
2001-09-02 01:48:06 +02:00
ds = NULL;
if( addrIndex->lastType == ADDR_IF_BOOK ) {
ds = addrindex_parse_book( file );
if( ds->rawDataSource ) {
addrbook_set_path( ds->rawDataSource,
addrIndex->filePath );
2001-09-02 01:48:06 +02:00
}
}
else if( addrIndex->lastType == ADDR_IF_VCARD ) {
ds = addrindex_parse_vcard( file );
}
else if( addrIndex->lastType == ADDR_IF_JPILOT ) {
ds = addrindex_parse_jpilot( file );
}
else if( addrIndex->lastType == ADDR_IF_LDAP ) {
ds = addrindex_parse_ldap( file );
}
if( ds ) {
ds->interface = dsIFace;
addrindex_hash_add_cache( addrIndex, ds );
dsIFace->listSource =
g_list_append( dsIFace->listSource, ds );
2001-09-02 01:48:06 +02:00
}
}
}
2003-06-21 08:23:00 +02:00
}
}
/*
* Search order sorting comparison function for building search order list.
*/
static gint addrindex_search_order_compare( gconstpointer ptrA, gconstpointer ptrB ) {
AddressInterface *ifaceA = ( AddressInterface * ) ptrA;
AddressInterface *ifaceB = ( AddressInterface * ) ptrB;
return ifaceA->searchOrder - ifaceB->searchOrder;
}
/**
* Build list of data sources to process.
* \param addrIndex Address index object.
*/
static void addrindex_build_search_order( AddressIndex *addrIndex ) {
GList *nodeIf;
/* Clear existing list */
g_list_free( addrIndex->searchOrder );
addrIndex->searchOrder = NULL;
/* Build new list */
nodeIf = addrIndex->interfaceList;
while( nodeIf ) {
AddressInterface *iface = nodeIf->data;
if( iface->useInterface ) {
if( iface->searchOrder > 0 ) {
/* Add to search order list */
addrIndex->searchOrder = g_list_insert_sorted(
addrIndex->searchOrder, iface,
addrindex_search_order_compare );
}
}
nodeIf = g_list_next( nodeIf );
2001-09-02 01:48:06 +02:00
}
}
static gint addrindex_read_file( AddressIndex *addrIndex ) {
XMLFile *file = NULL;
gchar *fileSpec = NULL;
2001-09-06 12:24:20 +02:00
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, -1 );
2001-09-02 01:48:06 +02:00
fileSpec = g_strconcat( addrIndex->filePath, G_DIR_SEPARATOR_S, addrIndex->fileName, NULL );
addrIndex->retVal = MGU_NO_FILE;
file = xml_open_file( fileSpec );
g_free( fileSpec );
if( file == NULL ) {
2003-06-21 08:23:00 +02:00
/*
g_print( " file '%s' does not exist.\n", addrIndex->fileName );
2003-06-21 08:23:00 +02:00
*/
2001-09-02 01:48:06 +02:00
return addrIndex->retVal;
}
addrIndex->retVal = MGU_BAD_FORMAT;
if( xml_get_dtd( file ) == 0 ) {
if( xml_parse_next_tag( file ) == 0 ) {
if( xml_compare_tag( file, TAG_ADDRESS_INDEX ) ) {
addrindex_read_index( addrIndex, file );
addrIndex->retVal = MGU_SUCCESS;
}
}
}
xml_close_file( file );
2003-06-21 08:23:00 +02:00
addrindex_build_search_order( addrIndex );
2001-09-02 01:48:06 +02:00
return addrIndex->retVal;
}
static int addrindex_write_index( AddressIndex *addrIndex, FILE *fp ) {
2001-09-02 01:48:06 +02:00
GList *nodeIF, *nodeDS;
gint lvlList = 1;
gint lvlItem = 1 + lvlList;
nodeIF = addrIndex->interfaceList;
while( nodeIF ) {
AddressInterface *iface = nodeIF->data;
if( ! iface->legacyFlag ) {
nodeDS = iface->listSource;
if (addrindex_write_elem_s( fp, lvlList, iface->listTag ) < 0)
return -1;
if (fputs( ">\n", fp ) == EOF)
return -1;
2001-09-02 01:48:06 +02:00
while( nodeDS ) {
AddressDataSource *ds = nodeDS->data;
if( ds ) {
if( iface->type == ADDR_IF_BOOK ) {
if (addrindex_write_book( fp, ds, lvlItem ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
}
if( iface->type == ADDR_IF_VCARD ) {
if (addrindex_write_vcard( fp, ds, lvlItem ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
}
if( iface->type == ADDR_IF_JPILOT ) {
if (addrindex_write_jpilot( fp, ds, lvlItem ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
}
if( iface->type == ADDR_IF_LDAP ) {
if (addrindex_write_ldap( fp, ds, lvlItem ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
}
}
nodeDS = g_list_next( nodeDS );
}
if (addrindex_write_elem_e( fp, lvlList, iface->listTag ) < 0)
return -1;
2001-09-02 01:48:06 +02:00
}
nodeIF = g_list_next( nodeIF );
}
return 0;
2001-09-02 01:48:06 +02:00
}
/*
* Write data to specified file.
* Enter: addrIndex Address index object.
* newFile New file name.
* return: Status code, from addrIndex->retVal.
* Note: File will be created in directory specified by addrIndex.
*/
static gint addrindex_write_to( AddressIndex *addrIndex, const gchar *newFile ) {
2001-09-02 01:48:06 +02:00
FILE *fp;
gchar *fileSpec;
#ifndef DEV_STANDALONE
PrefFile *pfile;
#endif
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, -1 );
2001-09-02 01:48:06 +02:00
fileSpec = g_strconcat( addrIndex->filePath, G_DIR_SEPARATOR_S, newFile, NULL );
addrIndex->retVal = MGU_OPEN_FILE;
#ifdef DEV_STANDALONE
fp = g_fopen( fileSpec, "wb" );
2001-09-02 01:48:06 +02:00
g_free( fileSpec );
if( fp ) {
fputs( "<?xml version=\"1.0\" ?>\n", fp );
#else
pfile = prefs_write_open( fileSpec );
g_free( fileSpec );
if( pfile ) {
fp = pfile->fp;
if (fprintf( fp, "<?xml version=\"1.0\" encoding=\"%s\" ?>\n", CS_INTERNAL ) < 0)
goto fail;
2001-09-02 01:48:06 +02:00
#endif
if (addrindex_write_elem_s( fp, 0, TAG_ADDRESS_INDEX ) < 0)
goto fail;
if (fputs( ">\n", fp ) == EOF)
goto fail;
2001-09-02 01:48:06 +02:00
if (addrindex_write_index( addrIndex, fp ) < 0)
goto fail;
if (addrindex_write_elem_e( fp, 0, TAG_ADDRESS_INDEX ) < 0)
goto fail;
2001-09-02 01:48:06 +02:00
addrIndex->retVal = MGU_SUCCESS;
#ifdef DEV_STANDALONE
fclose( fp );
#else
if( prefs_file_close( pfile ) < 0 ) {
2001-09-02 01:48:06 +02:00
addrIndex->retVal = MGU_ERROR_WRITE;
}
#endif
}
fileSpec = NULL;
return addrIndex->retVal;
fail:
g_warning("error writing AB index\n");
addrIndex->retVal = MGU_ERROR_WRITE;
if (pfile)
prefs_file_close_revert( pfile );
return addrIndex->retVal;
2001-09-02 01:48:06 +02:00
}
/*
* Save address index data to original file.
* return: Status code, from addrIndex->retVal.
*/
gint addrindex_save_data( AddressIndex *addrIndex ) {
#ifdef USE_LDAP
GList *nodeIf;
GList *nodeDS;
#endif
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, -1 );
#ifdef USE_LDAP
nodeIf = addrIndex->interfaceList;
/* save LDAP interfaces */
while ( nodeIf ) {
AddressInterface *iface = nodeIf->data;
if( iface->type == ADDR_IF_LDAP ) {
nodeDS = iface->listSource;
while( nodeDS ) {
AddressDataSource *ds = nodeDS->data;
LdapServer *abf = ds->rawDataSource;
if( ldapsvr_get_read_flag( abf ) ) {
if( ldapsvr_get_modified( abf ) ) {
ldapsvr_update_book( abf, NULL );
if( abf->retVal != LDAPRC_SUCCESS ) {
alertpanel( _("Address(es) update"),
_("Update failed. Changes not written to Directory."),
GTK_STOCK_CLOSE, NULL, NULL );
}
else {
abf->retVal = MGU_SUCCESS;
ldapsvr_set_modified( abf, FALSE );
}
}
}
nodeDS = g_list_next( nodeDS );
}
break;
}
nodeIf = g_list_next( nodeIf );
}
#endif
2001-09-02 01:48:06 +02:00
addrIndex->retVal = MGU_NO_FILE;
if( addrIndex->fileName == NULL || *addrIndex->fileName == '\0' ) return addrIndex->retVal;
if( addrIndex->filePath == NULL || *addrIndex->filePath == '\0' ) return addrIndex->retVal;
addrindex_write_to( addrIndex, addrIndex->fileName );
if( addrIndex->retVal == MGU_SUCCESS ) {
addrIndex->dirtyFlag = FALSE;
}
return addrIndex->retVal;
}
/*
* Save all address book files which may have changed.
* Return: Status code, set if there was a problem saving data.
*/
gint addrindex_save_all_books( AddressIndex *addrIndex ) {
gint retVal = MGU_SUCCESS;
GList *nodeIf, *nodeDS;
2001-09-06 12:24:20 +02:00
2001-09-02 01:48:06 +02:00
nodeIf = addrIndex->interfaceList;
while( nodeIf ) {
AddressInterface *iface = nodeIf->data;
if( iface->type == ADDR_IF_BOOK ) {
nodeDS = iface->listSource;
while( nodeDS ) {
AddressDataSource *ds = nodeDS->data;
AddressBookFile *abf = ds->rawDataSource;
if( addrbook_get_dirty( abf ) ) {
2002-03-16 07:10:46 +01:00
if( addrbook_get_read_flag( abf ) ) {
2001-09-02 01:48:06 +02:00
addrbook_save_data( abf );
if( abf->retVal != MGU_SUCCESS ) {
retVal = abf->retVal;
}
}
}
nodeDS = g_list_next( nodeDS );
}
break;
}
nodeIf = g_list_next( nodeIf );
}
return retVal;
}
/* **********************************************************************
* Address book conversion to new format.
* ***********************************************************************
*/
#define ELTAG_IF_OLD_FOLDER "folder"
#define ELTAG_IF_OLD_GROUP "group"
#define ELTAG_IF_OLD_ITEM "item"
#define ELTAG_IF_OLD_NAME "name"
#define ELTAG_IF_OLD_ADDRESS "address"
#define ELTAG_IF_OLD_REMARKS "remarks"
#define ATTAG_IF_OLD_NAME "name"
#define TEMPNODE_ROOT 0
#define TEMPNODE_FOLDER 1
#define TEMPNODE_GROUP 2
#define TEMPNODE_ADDRESS 3
typedef struct _AddressCvt_Node AddressCvtNode;
struct _AddressCvt_Node {
gint type;
gchar *name;
gchar *address;
gchar *remarks;
GList *list;
};
/*
* Parse current address item.
*/
static AddressCvtNode *addrindex_parse_item( XMLFile *file ) {
gchar *element;
guint level;
AddressCvtNode *nn;
nn = g_new0( AddressCvtNode, 1 );
nn->type = TEMPNODE_ADDRESS;
nn->list = NULL;
level = file->level;
for (;;) {
xml_parse_next_tag(file);
if (file->level < level) return nn;
element = xml_get_element( file );
if( xml_compare_tag( file, ELTAG_IF_OLD_NAME ) ) {
nn->name = g_strdup( element );
}
if( xml_compare_tag( file, ELTAG_IF_OLD_ADDRESS ) ) {
nn->address = g_strdup( element );
}
if( xml_compare_tag( file, ELTAG_IF_OLD_REMARKS ) ) {
nn->remarks = g_strdup( element );
}
g_free(element);
2001-09-02 01:48:06 +02:00
xml_parse_next_tag(file);
}
}
/*
* Create a temporary node below specified node.
*/
static AddressCvtNode *addrindex_add_object( AddressCvtNode *node, gint type, gchar *name, gchar *addr, char *rem ) {
AddressCvtNode *nn;
nn = g_new0( AddressCvtNode, 1 );
nn->type = type;
nn->name = g_strdup( name );
nn->remarks = g_strdup( rem );
node->list = g_list_append( node->list, nn );
return nn;
}
/*
* Process current temporary node.
*/
static void addrindex_add_obj( XMLFile *file, AddressCvtNode *node ) {
GList *attr;
guint prev_level;
AddressCvtNode *newNode = NULL;
gchar *name;
gchar *value;
for (;;) {
prev_level = file->level;
xml_parse_next_tag( file );
if (file->level < prev_level) return;
name = NULL;
value = NULL;
if( xml_compare_tag( file, ELTAG_IF_OLD_GROUP ) ) {
attr = xml_get_current_tag_attr(file);
if (attr) {
name = ((XMLAttr *)attr->data)->name;
if( strcmp( name, ATTAG_IF_OLD_NAME ) == 0 ) {
value = ((XMLAttr *)attr->data)->value;
}
}
newNode = addrindex_add_object( node, TEMPNODE_GROUP, value, "", "" );
addrindex_add_obj( file, newNode );
}
else if( xml_compare_tag( file, ELTAG_IF_OLD_FOLDER ) ) {
attr = xml_get_current_tag_attr(file);
if (attr) {
name = ((XMLAttr *)attr->data)->name;
if( strcmp( name, ATTAG_IF_OLD_NAME ) == 0 ) {
value = ((XMLAttr *)attr->data)->value;
}
}
newNode = addrindex_add_object( node, TEMPNODE_FOLDER, value, "", "" );
addrindex_add_obj( file, newNode );
}
else if( xml_compare_tag( file, ELTAG_IF_OLD_ITEM ) ) {
newNode = addrindex_parse_item( file );
node->list = g_list_append( node->list, newNode );
}
else {
/* g_print( "invalid: !!! \n" ); */
2001-09-02 01:48:06 +02:00
attr = xml_get_current_tag_attr( file );
}
}
}
/*
* Consume all nodes below current tag.
*/
static void addrindex_consume_tree( XMLFile *file ) {
guint prev_level;
gchar *element;
GList *attr;
XMLTag *xtag;
for (;;) {
prev_level = file->level;
xml_parse_next_tag( file );
if (file->level < prev_level) return;
xtag = xml_get_current_tag( file );
/* g_print( "tag : %s\n", xtag->tag ); */
2001-09-02 01:48:06 +02:00
element = xml_get_element( file );
attr = xml_get_current_tag_attr( file );
2001-09-30 13:07:34 +02:00
/* show_attribs( attr ); */
/* g_print( "\ttag value : %s :\n", element ); */
2001-09-02 01:48:06 +02:00
addrindex_consume_tree( file );
}
}
/*
* Free up temporary tree.
*/
static void addrindex_free_node( AddressCvtNode *node ) {
GList *list = node->list;
2001-09-06 12:24:20 +02:00
2001-09-02 01:48:06 +02:00
while( list ) {
AddressCvtNode *lNode = list->data;
list = g_list_next( list );
addrindex_free_node( lNode );
}
node->type = TEMPNODE_ROOT;
g_free( node->name );
g_free( node->address );
g_free( node->remarks );
g_list_free( node->list );
g_free( node );
}
/*
* Process address book for specified node.
*/
static void addrindex_process_node(
AddressBookFile *abf, AddressCvtNode *node, ItemFolder *parent,
ItemGroup *parentGrp, ItemFolder *folderGrp )
{
GList *list;
2001-09-06 12:24:20 +02:00
ItemFolder *itemFolder = NULL;
2001-09-02 01:48:06 +02:00
ItemGroup *itemGParent = parentGrp;
ItemFolder *itemGFolder = folderGrp;
AddressCache *cache = abf->addressCache;
if( node->type == TEMPNODE_ROOT ) {
itemFolder = parent;
}
else if( node->type == TEMPNODE_FOLDER ) {
itemFolder = addritem_create_item_folder();
addritem_folder_set_name( itemFolder, node->name );
addrcache_id_folder( cache, itemFolder );
addrcache_folder_add_folder( cache, parent, itemFolder );
itemGFolder = NULL;
}
else if( node->type == TEMPNODE_GROUP ) {
ItemGroup *itemGroup;
gchar *fName;
2001-09-30 13:07:34 +02:00
/* Create a folder for group */
2001-09-02 01:48:06 +02:00
fName = g_strdup_printf( "Cvt - %s", node->name );
itemGFolder = addritem_create_item_folder();
addritem_folder_set_name( itemGFolder, fName );
addrcache_id_folder( cache, itemGFolder );
addrcache_folder_add_folder( cache, parent, itemGFolder );
g_free( fName );
2001-09-30 13:07:34 +02:00
/* Add group into folder */
2001-09-02 01:48:06 +02:00
itemGroup = addritem_create_item_group();
addritem_group_set_name( itemGroup, node->name );
addrcache_id_group( cache, itemGroup );
addrcache_folder_add_group( cache, itemGFolder, itemGroup );
itemGParent = itemGroup;
}
else if( node->type == TEMPNODE_ADDRESS ) {
ItemPerson *itemPerson;
ItemEMail *itemEMail;
2001-09-30 13:07:34 +02:00
/* Create person and email objects */
2001-09-02 01:48:06 +02:00
itemPerson = addritem_create_item_person();
addritem_person_set_common_name( itemPerson, node->name );
addrcache_id_person( cache, itemPerson );
itemEMail = addritem_create_item_email();
addritem_email_set_address( itemEMail, node->address );
addritem_email_set_remarks( itemEMail, node->remarks );
addrcache_id_email( cache, itemEMail );
addrcache_person_add_email( cache, itemPerson, itemEMail );
2001-09-30 13:07:34 +02:00
/* Add person into appropriate folder */
2001-09-02 01:48:06 +02:00
if( itemGFolder ) {
addrcache_folder_add_person( cache, itemGFolder, itemPerson );
}
else {
addrcache_folder_add_person( cache, parent, itemPerson );
}
2001-09-30 13:07:34 +02:00
/* Add email address only into group */
2001-09-02 01:48:06 +02:00
if( parentGrp ) {
addrcache_group_add_email( cache, parentGrp, itemEMail );
}
}
list = node->list;
while( list ) {
AddressCvtNode *lNode = list->data;
list = g_list_next( list );
addrindex_process_node( abf, lNode, itemFolder, itemGParent, itemGFolder );
}
}
/*
* Process address book to specified file number.
*/
static gboolean addrindex_process_book( AddressIndex *addrIndex, XMLFile *file, gchar *displayName ) {
gboolean retVal = FALSE;
AddressBookFile *abf = NULL;
AddressCvtNode *rootNode = NULL;
gchar *newFile = NULL;
GList *fileList = NULL;
gint fileNum = 0;
2001-09-30 13:07:34 +02:00
/* Setup root node */
2001-09-02 01:48:06 +02:00
rootNode = g_new0( AddressCvtNode, 1 );
rootNode->type = TEMPNODE_ROOT;
rootNode->name = g_strdup( "root" );
rootNode->list = NULL;
addrindex_add_obj( file, rootNode );
2001-09-30 13:07:34 +02:00
/* addrindex_print_node( rootNode, stdout ); */
2001-09-02 01:48:06 +02:00
2001-09-30 13:07:34 +02:00
/* Create new address book */
2001-09-02 01:48:06 +02:00
abf = addrbook_create_book();
addrbook_set_name( abf, displayName );
addrbook_set_path( abf, addrIndex->filePath );
2001-09-30 13:07:34 +02:00
/* Determine next available file number */
2001-09-02 01:48:06 +02:00
fileList = addrbook_get_bookfile_list( abf );
if( fileList ) {
fileNum = 1 + abf->maxValue;
}
g_list_free( fileList );
fileList = NULL;
newFile = addrbook_gen_new_file_name( fileNum );
if( newFile ) {
addrbook_set_file( abf, newFile );
}
addrindex_process_node( abf, rootNode, abf->addressCache->rootFolder, NULL, NULL );
2001-09-30 13:07:34 +02:00
/* addrbook_dump_book( abf, stdout ); */
2001-09-02 01:48:06 +02:00
addrbook_save_data( abf );
addrIndex->retVal = abf->retVal;
if( abf->retVal == MGU_SUCCESS ) retVal = TRUE;
addrbook_free_book( abf );
abf = NULL;
addrindex_free_node( rootNode );
rootNode = NULL;
2001-09-30 13:07:34 +02:00
/* Create entries in address index */
2001-09-02 01:48:06 +02:00
if( retVal ) {
abf = addrbook_create_book();
addrbook_set_name( abf, displayName );
addrbook_set_path( abf, addrIndex->filePath );
addrbook_set_file( abf, newFile );
addrindex_index_add_datasource( addrIndex, ADDR_IF_BOOK, abf );
}
return retVal;
}
/*
* Process tree converting data.
*/
static void addrindex_convert_tree( AddressIndex *addrIndex, XMLFile *file ) {
guint prev_level;
gchar *element;
GList *attr;
XMLTag *xtag;
2001-09-30 13:07:34 +02:00
/* Process file */
2001-09-02 01:48:06 +02:00
for (;;) {
prev_level = file->level;
xml_parse_next_tag( file );
if (file->level < prev_level) return;
xtag = xml_get_current_tag( file );
/* g_print( "tag : %d : %s\n", prev_level, xtag->tag ); */
2001-09-02 01:48:06 +02:00
if( strcmp( xtag->tag, TAG_IF_OLD_COMMON ) == 0 ) {
if( addrindex_process_book( addrIndex, file, DISP_OLD_COMMON ) ) {
addrIndex->needsConversion = FALSE;
addrIndex->wasConverted = TRUE;
continue;
}
return;
}
if( strcmp( xtag->tag, TAG_IF_OLD_PERSONAL ) == 0 ) {
if( addrindex_process_book( addrIndex, file, DISP_OLD_PERSONAL ) ) {
addrIndex->needsConversion = FALSE;
addrIndex->wasConverted = TRUE;
continue;
}
return;
}
element = xml_get_element( file );
attr = xml_get_current_tag_attr( file );
2001-09-30 13:07:34 +02:00
/* show_attribs( attr ); */
/* g_print( "\ttag value : %s :\n", element ); */
2001-09-02 01:48:06 +02:00
addrindex_consume_tree( file );
}
}
static gint addrindex_convert_data( AddressIndex *addrIndex ) {
XMLFile *file = NULL;
gchar *fileSpec;
fileSpec = g_strconcat( addrIndex->filePath, G_DIR_SEPARATOR_S, addrIndex->fileName, NULL );
addrIndex->retVal = MGU_NO_FILE;
file = xml_open_file( fileSpec );
g_free( fileSpec );
if( file == NULL ) {
/* g_print( " file '%s' does not exist.\n", addrIndex->fileName ); */
2001-09-02 01:48:06 +02:00
return addrIndex->retVal;
}
addrIndex->retVal = MGU_BAD_FORMAT;
if( xml_get_dtd( file ) == 0 ) {
if( xml_parse_next_tag( file ) == 0 ) {
if( xml_compare_tag( file, TAG_ADDRESS_INDEX ) ) {
addrindex_convert_tree( addrIndex, file );
}
}
}
xml_close_file( file );
return addrIndex->retVal;
}
/*
* Create a new address book file.
*/
static gboolean addrindex_create_new_book( AddressIndex *addrIndex, gchar *displayName ) {
gboolean retVal = FALSE;
AddressBookFile *abf = NULL;
gchar *newFile = NULL;
GList *fileList = NULL;
gint fileNum = 0;
2001-09-30 13:07:34 +02:00
/* Create new address book */
2001-09-02 01:48:06 +02:00
abf = addrbook_create_book();
addrbook_set_name( abf, displayName );
addrbook_set_path( abf, addrIndex->filePath );
2001-09-30 13:07:34 +02:00
/* Determine next available file number */
2001-09-02 01:48:06 +02:00
fileList = addrbook_get_bookfile_list( abf );
if( fileList ) {
fileNum = 1 + abf->maxValue;
}
g_list_free( fileList );
fileList = NULL;
newFile = addrbook_gen_new_file_name( fileNum );
if( newFile ) {
addrbook_set_file( abf, newFile );
}
addrbook_save_data( abf );
addrIndex->retVal = abf->retVal;
if( abf->retVal == MGU_SUCCESS ) retVal = TRUE;
addrbook_free_book( abf );
abf = NULL;
2001-09-30 13:07:34 +02:00
/* Create entries in address index */
2001-09-02 01:48:06 +02:00
if( retVal ) {
abf = addrbook_create_book();
addrbook_set_name( abf, displayName );
addrbook_set_path( abf, addrIndex->filePath );
addrbook_set_file( abf, newFile );
addrindex_index_add_datasource( addrIndex, ADDR_IF_BOOK, abf );
}
return retVal;
}
/*
* Read data for address index performing a conversion if necesary.
* Enter: addrIndex Address index object.
* return: Status code, from addrIndex->retVal.
* Note: New address book files will be created in directory specified by
* addrIndex. Three files will be created, for the following:
* "Common addresses"
* "Personal addresses"
* "Gathered addresses" - a new address book.
*/
gint addrindex_read_data( AddressIndex *addrIndex ) {
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, -1 );
2001-09-02 01:48:06 +02:00
addrIndex->conversionError = FALSE;
addrindex_read_file( addrIndex );
if( addrIndex->retVal == MGU_SUCCESS ) {
if( addrIndex->needsConversion ) {
if( addrindex_convert_data( addrIndex ) == MGU_SUCCESS )
addrIndex->conversionError = FALSE;
else
2001-09-02 01:48:06 +02:00
addrIndex->conversionError = TRUE;
}
addrIndex->dirtyFlag = TRUE;
}
return addrIndex->retVal;
}
/*
* Create new address books for a new address index.
* Enter: addrIndex Address index object.
* return: Status code, from addrIndex->retVal.
* Note: New address book files will be created in directory specified by
* addrIndex. Three files will be created, for the following:
* "Common addresses"
* "Personal addresses"
* "Gathered addresses" - a new address book.
*/
gint addrindex_create_new_books( AddressIndex *addrIndex ) {
gboolean flg;
2009-02-23 [cleroy] 3.7.0cvs73 * src/account.c * src/action.c * src/addr_compl.c * src/addrbook.c * src/addrcache.c * src/addrcindex.c * src/addrclip.c * src/addrduplicates.c * src/addressadd.c * src/addressbook.c * src/addressbook_foldersel.c * src/addrharvest.c * src/addrindex.c * src/addritem.c * src/addrquery.c * src/addrselect.c * src/codeconv.c * src/compose.c * src/customheader.c * src/editaddress.c * src/editaddress_other_attributes_ldap.c * src/editgroup.c * src/editldap.c * src/enriched.c * src/exporthtml.c * src/exportldif.c * src/filtering.c * src/folder.c * src/foldersel.c * src/folderutils.c * src/folderview.c * src/gedit-print.c * src/html.c * src/imap.c * src/imap_gtk.c * src/inc.c * src/jpilot.c * src/ldapctrl.c * src/ldapquery.c * src/ldapserver.c * src/ldapupdate.c * src/ldif.c * src/localfolder.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/mutt.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/pine.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_column.c * src/prefs_folder_item.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_quote.c * src/prefs_send.c * src/prefs_summaries.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/printing.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/remotefolder.c * src/send_message.c * src/sourcewindow.c * src/statusbar.c * src/stock_pixmap.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/undo.c * src/uri_opener.c * src/vcard.c * src/common/base64.c * src/common/claws.c * src/common/hooks.c * src/common/plugin.c * src/common/prefs.c * src/common/session.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/stringtable.c * src/common/utils.c * src/common/utils.h * src/common/xml.c * src/common/xmlprops.c * src/gtk/colorlabel.c * src/gtk/combobox.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkcmclist.c * src/gtk/gtkcmctree.c * src/gtk/gtkcmoptionmenu.c * src/gtk/gtksctree.c * src/gtk/gtkshruler.c * src/gtk/gtksourceprintjob.c * src/gtk/gtkutils.c * src/gtk/gtkvscrollbutton.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/quicksearch.c * src/gtk/spell_entry.c * src/plugins/pgpcore/select-keys.c * src/plugins/pgpinline/pgpinline.c * src/plugins/pgpmime/pgpmime.c * src/plugins/smime/smime.c * src/plugins/spamassassin/spamassassin_gtk.c Mass commit changing g_return_* to cm_return_* and making these more interesting
2009-02-23 17:55:51 +01:00
cm_return_val_if_fail( addrIndex != NULL, -1 );
2001-09-02 01:48:06 +02:00
flg = addrindex_create_new_book( addrIndex, DISP_NEW_COMMON );
if( flg ) {
flg = addrindex_create_new_book( addrIndex, DISP_NEW_PERSONAL );
addrIndex->dirtyFlag = TRUE;
}
return addrIndex->retVal;
}
/* **********************************************************************
* New interface stuff.
* ***********************************************************************
*/
/*
* Return modified flag for specified data source.
*/
gboolean addrindex_ds_get_modify_flag( AddressDataSource *ds ) {
gboolean retVal = FALSE;
AddressInterface *iface;
if( ds == NULL ) return retVal;
iface = ds->interface;
if( iface == NULL ) return retVal;
if( iface->getModifyFlag ) {
retVal = ( iface->getModifyFlag ) ( ds->rawDataSource );
}
return retVal;
}
/*
* Return accessed flag for specified data source.
*/
gboolean addrindex_ds_get_access_flag( AddressDataSource *ds ) {
gboolean retVal = FALSE;
AddressInterface *iface;
if( ds == NULL ) return retVal;
iface = ds->interface;
if( iface == NULL ) return retVal;
if( iface->getAccessFlag ) {
retVal = ( iface->getAccessFlag ) ( ds->rawDataSource );
}
return retVal;
}
/*
* Return data read flag for specified data source.
*/
gboolean addrindex_ds_get_read_flag( AddressDataSource *ds ) {
gboolean retVal = TRUE;
AddressInterface *iface;
if( ds == NULL ) return retVal;
iface = ds->interface;
if( iface == NULL ) return retVal;
if( iface->getReadFlag ) {
retVal = ( iface->getReadFlag ) ( ds->rawDataSource );
}
return retVal;
}
/*
* Return status code for specified data source.
*/
gint addrindex_ds_get_status_code( AddressDataSource *ds ) {
gint retVal = MGU_SUCCESS;
AddressInterface *iface;
if( ds == NULL ) return retVal;
iface = ds->interface;
if( iface == NULL ) return retVal;
if( iface->getStatusCode ) {
retVal = ( iface->getStatusCode ) ( ds->rawDataSource );
}
return retVal;
}
/*
* Return data read flag for specified data source.
*/
gint addrindex_ds_read_data( AddressDataSource *ds ) {
gint retVal = MGU_SUCCESS;
AddressInterface *iface;
if( ds == NULL ) return retVal;
iface = ds->interface;
if( iface == NULL ) return retVal;
if( iface->getReadData ) {
/*
2003-06-21 08:23:00 +02:00
gchar *name = ( iface->getName ) ( ds->rawDataSource );
g_print( "addrindex_ds_read_data...reading:::%s:::\n", name );
*/
2001-09-02 01:48:06 +02:00
retVal = ( iface->getReadData ) ( ds->rawDataSource );
}
return retVal;
}
/*
* Return data read flag for specified data source.
*/
ItemFolder *addrindex_ds_get_root_folder( AddressDataSource *ds ) {
ItemFolder *retVal = NULL;
AddressInterface *iface;
if( ds == NULL ) return retVal;
iface = ds->interface;
if( iface == NULL ) return retVal;
if( iface->getRootFolder ) {
retVal = ( iface->getRootFolder ) ( ds->rawDataSource );
}
return retVal;
}
/*
* Return name for specified data source.
*/
gchar *addrindex_ds_get_name( AddressDataSource *ds ) {
gchar *retVal = FALSE;
AddressInterface *iface;
if( ds == NULL ) return retVal;
iface = ds->interface;
if( iface == NULL ) return retVal;
if( iface->getName ) {
retVal = ( iface->getName ) ( ds->rawDataSource );
}
return retVal;
}
/*
* Set the access flag inside the data source.
*/
void addrindex_ds_set_access_flag( AddressDataSource *ds, gboolean *value ) {
AddressInterface *iface;
if( ds == NULL ) return;
iface = ds->interface;
if( iface == NULL ) return;
if( iface->setAccessFlag ) {
( iface->setAccessFlag ) ( ds->rawDataSource, value );
}
}
/*
* Return read only flag for specified data source.
*/
gboolean addrindex_ds_get_readonly( AddressDataSource *ds ) {
AddressInterface *iface;
if( ds == NULL ) return TRUE;
iface = ds->interface;
if( iface == NULL ) return TRUE;
return iface->readOnly;
}
/*
* Return list of all persons for specified data source.
*/
static GList *addrindex_ds_get_all_persons( AddressDataSource *ds ) {
2001-09-02 01:48:06 +02:00
GList *retVal = NULL;
AddressInterface *iface;
if( ds == NULL ) return retVal;
iface = ds->interface;
if( iface == NULL ) return retVal;
if( iface->getAllPersons ) {
retVal = ( iface->getAllPersons ) ( ds->rawDataSource );
}
return retVal;
}
2001-09-24 07:42:50 +02:00
/*
* Return list of all groups for specified data source.
*/
static GList *addrindex_ds_get_all_groups( AddressDataSource *ds ) {
2001-09-24 07:42:50 +02:00
GList *retVal = NULL;
AddressInterface *iface;
if( ds == NULL ) return retVal;
iface = ds->interface;
if( iface == NULL ) return retVal;
if( iface->getAllGroups ) {
retVal = ( iface->getAllGroups ) ( ds->rawDataSource );
}
return retVal;
}
2003-06-21 08:23:00 +02:00
/* **********************************************************************
* Address search stuff.
* ***********************************************************************
*/
2003-06-21 08:23:00 +02:00
/**
2004-01-12 22:28:31 +01:00
* Setup or register the dynamic search that will be performed. The search
* is registered with the query manager.
*
* \param searchTerm Search term. A private copy will be made.
* \param callBackEntry Callback function that should be called when
* each entry is received.
* \param callBackEnd Callback function that should be called when
* search has finished running.
2003-06-21 08:23:00 +02:00
* \return ID allocated to query that will be executed.
*/
gint addrindex_setup_search(
2004-01-12 22:28:31 +01:00
const gchar *searchTerm, void *callBackEnd, void *callBackEntry )
2003-06-21 08:23:00 +02:00
{
2004-01-12 22:28:31 +01:00
QueryRequest *req;
2003-06-21 08:23:00 +02:00
gint queryID;
2004-01-12 22:28:31 +01:00
/* Set up a dynamic address query */
req = qrymgr_add_request( searchTerm, callBackEnd, callBackEntry );
queryID = req->queryID;
qryreq_set_search_type( req, ADDRSEARCH_DYNAMIC );
2003-06-21 08:23:00 +02:00
/* g_print( "***> query ID ::%d::\n", queryID ); */
2003-06-21 08:23:00 +02:00
return queryID;
}
#ifdef USE_LDAP
2003-09-07 21:28:56 +02:00
/*
2004-01-12 22:28:31 +01:00
* Function prototypes (not in header file or circular reference errors are
* encountered!)
2003-09-07 21:28:56 +02:00
*/
2004-01-12 22:28:31 +01:00
LdapQuery *ldapsvr_new_dynamic_search(
LdapServer *server, QueryRequest *req );
LdapQuery *ldapsvr_new_explicit_search(
LdapServer *server, QueryRequest *req, ItemFolder *folder );
void ldapsvr_execute_query( LdapServer *server, LdapQuery *qry );
2003-06-21 08:23:00 +02:00
#endif
/**
2004-01-12 22:28:31 +01:00
* Execute the previously registered dynamic search.
*
* \param req Address query object to execute.
2003-06-21 08:23:00 +02:00
* \return <i>TRUE</i> if search started successfully, or <i>FALSE</i> if
* failed.
*/
2004-01-12 22:28:31 +01:00
static gboolean addrindex_start_dynamic( QueryRequest *req ) {
2003-06-21 08:23:00 +02:00
AddressInterface *iface;
AddressDataSource *ds;
GList *nodeIf;
GList *nodeDS;
gint type;
/* g_print( "addrindex_start_dynamic::%d::\n", req->queryID ); */
2004-01-12 22:28:31 +01:00
nodeIf = _addressIndex_->searchOrder;
2003-06-21 08:23:00 +02:00
while( nodeIf ) {
iface = nodeIf->data;
nodeIf = g_list_next( nodeIf );
if( ! iface->useInterface ) {
continue;
}
if( ! iface->externalQuery ) {
continue;
}
type = iface->type;
nodeDS = iface->listSource;
while( nodeDS ) {
ds = nodeDS->data;
nodeDS = g_list_next( nodeDS );
#ifdef USE_LDAP
if( type == ADDR_IF_LDAP ) {
2004-01-12 22:28:31 +01:00
LdapServer *server;
LdapQuery *qry;
server = ds->rawDataSource;
if( ! server->searchFlag ) {
continue;
}
if( ldapsvr_reuse_previous( server, req ) ) {
continue;
}
/* Start a new dynamic search */
qry = ldapsvr_new_dynamic_search( server, req );
if( qry ) {
ldapsvr_execute_query( server, qry );
}
2003-06-21 08:23:00 +02:00
}
#endif
}
}
return TRUE;
}
/**
* Stop the previously registered search.
2004-01-12 22:28:31 +01:00
*
2003-06-21 08:23:00 +02:00
* \param queryID ID of search query to stop.
*/
2004-01-12 22:28:31 +01:00
void addrindex_stop_search( const gint queryID ){
QueryRequest *req;
AddrQueryObject *aqo;
GList *node;
2003-06-21 08:23:00 +02:00
/* g_print( "addrindex_stop_search/queryID=%d\n", queryID ); */
2003-06-21 08:23:00 +02:00
/* If query ID does not match, search has not been setup */
2004-01-12 22:28:31 +01:00
req = qrymgr_find_request( queryID );
if( req == NULL ) {
return;
2003-06-21 08:23:00 +02:00
}
2004-01-12 22:28:31 +01:00
/* Stop all queries that were associated with request */
node = req->queryList;
while( node ) {
aqo = node->data;
2003-09-07 21:28:56 +02:00
#ifdef USE_LDAP
2004-01-12 22:28:31 +01:00
if( aqo->queryType == ADDRQUERY_LDAP ) {
LdapQuery *qry = ( LdapQuery * ) aqo;
ldapqry_set_stop_flag( qry, TRUE );
}
#endif
node->data = NULL;
node = g_list_next( node );
2003-09-07 21:28:56 +02:00
}
2004-01-12 22:28:31 +01:00
/* Delete query request */
qrymgr_delete_request( queryID );
2003-09-07 21:28:56 +02:00
}
/**
2004-01-12 22:28:31 +01:00
* Setup or register the explicit search that will be performed. The search is
* registered with the query manager.
2003-09-07 21:28:56 +02:00
*
2004-01-12 22:28:31 +01:00
* \param ds Data source to search.
* \param searchTerm Search term to locate.
* \param folder Folder to receive search results; may be NULL.
* \param callbackEnd Function to call when search has terminated.
* \param callbackEntry Function to called for each entry processed.
2003-09-07 21:28:56 +02:00
* \return ID allocated to query that will be executed.
*/
2004-01-12 22:28:31 +01:00
gint addrindex_setup_explicit_search(
2003-09-07 21:28:56 +02:00
AddressDataSource *ds, const gchar *searchTerm, ItemFolder *folder,
2004-01-12 22:28:31 +01:00
void *callBackEnd, void *callBackEntry )
2003-09-07 21:28:56 +02:00
{
2004-01-12 22:28:31 +01:00
QueryRequest *req;
2003-09-07 21:28:56 +02:00
gint queryID;
gchar *name;
gchar *mySearch;
2003-09-07 21:28:56 +02:00
/* Name the query */
name = g_strdup_printf( "Search '%s'", searchTerm );
2004-01-12 22:28:31 +01:00
/* Set up query request */
if (!strcmp(searchTerm, "*"))
mySearch = g_strdup("*@");
else
mySearch = g_strdup(searchTerm);
req = qrymgr_add_request( mySearch, callBackEnd, callBackEntry );
g_free(mySearch);
2004-01-12 22:28:31 +01:00
qryreq_set_search_type( req, ADDRSEARCH_EXPLICIT );
queryID = req->queryID;
2003-09-07 21:28:56 +02:00
if( ds->type == ADDR_IF_LDAP ) {
#ifdef USE_LDAP
LdapServer *server;
server = ds->rawDataSource;
2004-01-12 22:28:31 +01:00
ldapsvr_new_explicit_search( server, req, folder );
2003-09-07 21:28:56 +02:00
#endif
}
else {
2004-01-12 22:28:31 +01:00
qrymgr_delete_request( queryID );
2003-09-07 21:28:56 +02:00
queryID = 0;
}
g_free( name );
return queryID;
}
/**
2004-01-12 22:28:31 +01:00
* Execute the previously registered explicit search.
*
* \param req Address query request object to execute.
2003-09-07 21:28:56 +02:00
* \return <i>TRUE</i> if search started successfully, or <i>FALSE</i> if
* failed.
*/
2004-01-12 22:28:31 +01:00
static gboolean addrindex_start_explicit( QueryRequest *req ) {
2003-09-07 21:28:56 +02:00
gboolean retVal;
2004-01-12 22:28:31 +01:00
AddrQueryObject *aqo;
2003-09-07 21:28:56 +02:00
retVal = FALSE;
2004-01-12 22:28:31 +01:00
/* Note: there should only be one query in the list. */
aqo = req->queryList->data;
2003-09-07 21:28:56 +02:00
#ifdef USE_LDAP
2004-01-12 22:28:31 +01:00
if( aqo->queryType == ADDRQUERY_LDAP ) {
2003-09-07 21:28:56 +02:00
LdapServer *server;
LdapQuery *qry;
2004-01-12 22:28:31 +01:00
qry = ( LdapQuery * ) aqo;
server = qry->server;
2003-09-07 21:28:56 +02:00
/* Start the search */
retVal = TRUE;
2004-01-12 22:28:31 +01:00
ldapsvr_execute_query( server, qry );
}
2003-09-07 21:28:56 +02:00
#endif
2004-01-12 22:28:31 +01:00
return retVal;
}
/**
* Start the previously registered search.
*
* \param queryID ID of search query to be executed.
* \return <i>TRUE</i> if search started successfully, or <i>FALSE</i> if
* failed.
*/
gboolean addrindex_start_search( const gint queryID ) {
gboolean retVal;
QueryRequest *req;
AddrSearchType searchType;
retVal = FALSE;
/* g_print( "addrindex_start_search/queryID=%d\n", queryID ); */
2004-01-12 22:28:31 +01:00
req = qrymgr_find_request( queryID );
if( req == NULL ) {
return retVal;
2003-09-07 21:28:56 +02:00
}
2004-01-12 22:28:31 +01:00
searchType = req->searchType;
if( searchType == ADDRSEARCH_DYNAMIC ) {
retVal = addrindex_start_dynamic( req );
}
else if( searchType == ADDRSEARCH_EXPLICIT ) {
retVal = addrindex_start_explicit( req );
2003-09-07 21:28:56 +02:00
}
return retVal;
}
2003-06-21 08:23:00 +02:00
/**
2004-01-12 22:28:31 +01:00
* Remove results (folder and data) for specified data source and folder.
* \param ds Data source to process.
* \param folder Results folder to remove.
2003-06-21 08:23:00 +02:00
*/
2004-01-12 22:28:31 +01:00
void addrindex_remove_results( AddressDataSource *ds, ItemFolder *folder ) {
AddrBookBase *adbase;
AddressCache *cache;
gint queryID = 0;
2003-06-21 08:23:00 +02:00
/* g_print( "addrindex_remove_results/start\n" ); */
2004-05-10 12:22:28 +02:00
2004-01-12 22:28:31 +01:00
/* Test for folder */
if( folder->folderType != ADDRFOLDER_QUERY_RESULTS ) return;
/* g_print( "folder name ::%s::\n", ADDRITEM_NAME(folder) ); */
2004-01-12 22:28:31 +01:00
adbase = ( AddrBookBase * ) ds->rawDataSource;
if( adbase == NULL ) return;
cache = adbase->addressCache;
2003-06-21 08:23:00 +02:00
2004-01-12 22:28:31 +01:00
/* Hide folder to prevent re-display */
addritem_folder_set_hidden( folder, TRUE );
2003-06-21 08:23:00 +02:00
2004-01-12 22:28:31 +01:00
if( ds->type == ADDR_IF_LDAP ) {
#ifdef USE_LDAP
2004-05-10 12:22:28 +02:00
LdapQuery *qry;
gboolean delFlag;
2003-06-21 08:23:00 +02:00
2004-01-12 22:28:31 +01:00
qry = ( LdapQuery * ) folder->folderData;
queryID = ADDRQUERY_ID(qry);
/* g_print( "calling ldapquery_remove_results...queryID=%d\n", queryID ); */
2004-05-10 12:22:28 +02:00
delFlag = ldapquery_remove_results( qry );
if (delFlag) {
ldapqry_free( qry );
}
/* g_print( "calling ldapquery_remove_results...done\n" ); */
2004-05-10 12:22:28 +02:00
/*
if( delFlag ) {
g_print( "delFlag IS-TRUE\n" );
2004-05-10 12:22:28 +02:00
}
else {
g_print( "delFlag IS-FALSE\n" );
2004-05-10 12:22:28 +02:00
}
*/
2004-01-12 22:28:31 +01:00
#endif
}
/* g_print( "addrindex_remove_results/end\n" ); */
2004-01-12 22:28:31 +01:00
/* Delete query request */
if( queryID > 0 ) {
qrymgr_delete_request( queryID );
2003-06-21 08:23:00 +02:00
}
}
2004-01-12 22:28:31 +01:00
/* **********************************************************************
* Address completion stuff.
* ***********************************************************************
*/
static void addrindex_load_completion_load_persons(
2004-05-10 12:22:28 +02:00
gint (*callBackFunc) ( const gchar *, const gchar *,
const gchar *, const gchar *, GList * ),
AddressDataSource *ds)
2003-06-21 08:23:00 +02:00
{
GList *listP, *nodeP;
GList *nodeM;
2004-05-10 12:22:28 +02:00
gchar *sName;
2003-06-21 08:23:00 +02:00
/* Read address book */
if( addrindex_ds_get_modify_flag( ds ) ) {
addrindex_ds_read_data( ds );
}
2003-06-21 08:23:00 +02:00
if( ! addrindex_ds_get_read_flag( ds ) ) {
addrindex_ds_read_data( ds );
}
2003-06-21 08:23:00 +02:00
/* Get all groups */
listP = addrindex_ds_get_all_groups( ds );
nodeP = listP;
while( nodeP ) {
ItemGroup *group = nodeP->data;
GList *emails = NULL;
for (nodeM = group->listEMail; nodeM; nodeM = g_list_next(nodeM)) {
ItemEMail *email = nodeM->data;
if (email->address)
emails = g_list_append(emails, email);
}
callBackFunc( ((AddrItemObject *)group)->name, NULL,
NULL, NULL, emails );
nodeP = g_list_next( nodeP );
}
2003-06-21 08:23:00 +02:00
/* Free up the list */
g_list_free( listP );
/* Get all persons */
listP = addrindex_ds_get_all_persons( ds );
nodeP = listP;
while( nodeP ) {
ItemPerson *person = nodeP->data;
nodeM = person->listEMail;
/* Figure out name to use */
sName = ADDRITEM_NAME(person);
if( sName == NULL || *sName == '\0' ) {
sName = person->nickName;
}
/* Process each E-Mail address */
while( nodeM ) {
ItemEMail *email = nodeM->data;
callBackFunc( sName, email->address, person->nickName,
ADDRITEM_NAME(email), NULL );
nodeM = g_list_next( nodeM );
}
nodeP = g_list_next( nodeP );
}
/* Free up the list */
g_list_free( listP );
}
2003-06-21 08:23:00 +02:00
/**
* This function is used by the address completion function to load
* addresses for all non-external address book interfaces.
*
* \param callBackFunc Function to be called when an address is
* to be loaded.
* \param folderpath Addressbook's Book/folder path to restrict to (if NULL or ""
* or "Any", assume the whole addressbook
* \return <i>TRUE</i> if data loaded, <i>FALSE</i> if address index not loaded.
*/
gboolean addrindex_load_completion(
gint (*callBackFunc) ( const gchar *, const gchar *,
const gchar *, const gchar *, GList * ),
gchar *folderpath )
{
GList *nodeIf, *nodeDS;
if( folderpath != NULL ) {
AddressDataSource *book;
ItemFolder* folder;
/* split the folder path we've received, we'll try to match this path, subpath by
subpath against the book/folder structure in order and restrict loading of
addresses to that subpart (if matches). book/folder path must exist and
folderpath must not be empty or NULL */
if( ! addressbook_peek_folder_exists( folderpath, &book, &folder ) ) {
g_warning("addrindex_load_completion: folder path '%s' doesn't exist\n", folderpath);
return FALSE;
}
if( folder != NULL ) {
GList *items;
GList *nodeM;
gchar *sName;
ItemPerson *person;
debug_print("addrindex_load_completion: folder %p '%s'\n", folder, folder->obj.name);
/* Load email addresses */
items = addritem_folder_get_person_list( folder );
for( ; items != NULL; items = g_list_next( items ) ) {
person = items->data;
nodeM = person->listEMail;
/* Figure out name to use */
sName = ADDRITEM_NAME(person);
if( sName == NULL || *sName == '\0' ) {
sName = person->nickName;
}
/* Process each E-Mail address */
while( nodeM ) {
ItemEMail *email = nodeM->data;
callBackFunc( sName, email->address, person->nickName,
ADDRITEM_NAME(email), NULL );
nodeM = g_list_next( nodeM );
}
}
/* Free up the list */
mgu_clear_list( items );
g_list_free( items );
return TRUE;
} else {
if( book != NULL ) {
AddressBookFile *abf = book->rawDataSource;
debug_print("addrindex_load_completion: book %p '%s'\n", book, abf?abf->fileName:"(null)");
addrindex_load_completion_load_persons( callBackFunc, book );
return TRUE;
} else {
g_warning("addrindex_load_completion: book/folder path is valid but got no pointer\n");
}
}
return FALSE;
} else {
nodeIf = addrindex_get_interface_list( _addressIndex_ );
while( nodeIf ) {
AddressInterface *iface = nodeIf->data;
nodeIf = g_list_next( nodeIf );
if( ! iface->useInterface || iface->externalQuery )
continue;
nodeDS = iface->listSource;
while( nodeDS ) {
addrindex_load_completion_load_persons( callBackFunc, nodeDS->data );
2003-06-21 08:23:00 +02:00
nodeDS = g_list_next( nodeDS );
}
}
}
2003-06-21 08:23:00 +02:00
return TRUE;
}
/**
* This function can be used to collect information about
* addressbook entries that contain a specific attribute.
*
* \param attr Name of attribute to look for
* \param callBackFunc Function to be called when a matching attribute was found
* \return <i>TRUE</i>
2003-06-21 08:23:00 +02:00
*/
gboolean addrindex_load_person_attribute(
const gchar *attr,
gint (*callBackFunc) ( ItemPerson *, const gchar * ) )
{
AddressDataSource *ds;
GList *nodeIf, *nodeDS;
GList *listP, *nodeP;
GList *nodeA;
nodeIf = addrindex_get_interface_list( _addressIndex_ );
while( nodeIf ) {
gchar *cur_bname;
AddressInterface *iface = nodeIf->data;
nodeIf = g_list_next( nodeIf );
if( ! iface->useInterface || iface->externalQuery )
continue;
nodeDS = iface->listSource;
while( nodeDS ) {
ds = nodeDS->data;
/* Read address book */
if( addrindex_ds_get_modify_flag( ds ) ) {
addrindex_ds_read_data( ds );
}
if( ! addrindex_ds_get_read_flag( ds ) ) {
addrindex_ds_read_data( ds );
}
2003-06-21 08:23:00 +02:00
/* Check addressbook name */
cur_bname = addrindex_ds_get_name( ds );
2003-06-21 08:23:00 +02:00
/* Get all persons */
listP = addrindex_ds_get_all_persons( ds );
nodeP = listP;
while( nodeP ) {
ItemPerson *person = nodeP->data;
/* Return all ItemPerson's if attr is NULL */
if( attr == NULL ) {
callBackFunc(person, cur_bname);
}
/* Return ItemPerson's with specific attribute */
else {
nodeA = person->listAttrib;
/* Process each User Attribute */
while( nodeA ) {
UserAttribute *attrib = nodeA->data;
if( attrib->name &&
!strcmp( attrib->name,attr ) ) {
callBackFunc(person, cur_bname);
}
nodeA = g_list_next( nodeA );
}
}
nodeP = g_list_next( nodeP );
}
/* Free up the list */
g_list_free( listP );
nodeDS = g_list_next( nodeDS );
}
}
return TRUE;
}
/**
* This function can be used to collect information about
* addressbook entries
*
* \param callBackFunc Function to be called for each ItemPerson
* \return <i>TRUE</i>
*/
gboolean addrindex_load_person_ds( gint (*callBackFunc)
( ItemPerson *, AddressDataSource * ) )
{
AddressDataSource *ds;
GList *nodeIf, *nodeDS;
GList *listP, *nodeP;
nodeIf = addrindex_get_interface_list( _addressIndex_ );
while( nodeIf ) {
AddressInterface *iface = nodeIf->data;
nodeIf = g_list_next( nodeIf );
if( ! iface->useInterface || iface->externalQuery )
continue;
nodeDS = iface->listSource;
while( nodeDS ) {
ds = nodeDS->data;
/* Read address book */
if( addrindex_ds_get_modify_flag( ds ) ) {
addrindex_ds_read_data( ds );
}
if( ! addrindex_ds_get_read_flag( ds ) ) {
addrindex_ds_read_data( ds );
}
/* Get all persons */
listP = addrindex_ds_get_all_persons( ds );
nodeP = listP;
while( nodeP ) {
ItemPerson *person = nodeP->data;
callBackFunc(person, ds);
nodeP = g_list_next( nodeP );
}
/* Free up the list */
g_list_free( listP );
nodeDS = g_list_next( nodeDS );
}
}
return TRUE;
}
gchar *addrindex_get_picture_file(const gchar *emailaddr)
{
AddressDataSource *ds;
GList *nodeIf, *nodeDS;
GList *listP, *nodeP;
gboolean found = FALSE;
gchar *filename = NULL;
gchar *raw_addr = NULL;
if (!emailaddr)
return NULL;
Xstrdup_a(raw_addr, emailaddr, return NULL);
extract_address(raw_addr);
nodeIf = addrindex_get_interface_list( _addressIndex_ );
while( nodeIf ) {
AddressInterface *iface = nodeIf->data;
nodeIf = g_list_next( nodeIf );
if( ! iface->useInterface || iface->externalQuery )
continue;
nodeDS = iface->listSource;
while( nodeDS && !found) {
ds = nodeDS->data;
/* Read address book */
if( addrindex_ds_get_modify_flag( ds ) ) {
addrindex_ds_read_data( ds );
}
if( ! addrindex_ds_get_read_flag( ds ) ) {
addrindex_ds_read_data( ds );
}
/* Get all persons */
listP = addrindex_ds_get_all_persons( ds );
nodeP = listP;
while( nodeP ) {
GList *nodeM;
ItemPerson *person = nodeP->data;
nodeM = person->listEMail;
while(nodeM) {
ItemEMail *email = nodeM->data;
if (email->address && !strcasecmp(raw_addr, email->address)) {
found = TRUE;
filename = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S,
ADDRBOOK_DIR, G_DIR_SEPARATOR_S,
person->picture, ".png", NULL );
break;
}
nodeM = nodeM->next;
}
nodeP = g_list_next( nodeP );
}
/* Free up the list */
g_list_free( listP );
nodeDS = g_list_next( nodeDS );
}
}
return filename;
}
/*
* End of Source.
*/