From: Paul Mangan Date: Mon, 27 Aug 2001 11:07:43 +0000 (+0000) Subject: sync with sylpheed 0.5.3cvs9 X-Git-Tag: pre_compose_gui_improvement~35 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=ec31c988b753b2e80f8a3e318d3742a59d877722 sync with sylpheed 0.5.3cvs9 --- diff --git a/ABOUT-NLS b/ABOUT-NLS index 7e6b38093..a4fb870be 100644 --- a/ABOUT-NLS +++ b/ABOUT-NLS @@ -164,102 +164,124 @@ Available Packages ================== Languages are not equally supported in all packages. The following -matrix shows the current state of internationalization, as of May 2001. -The matrix shows, in regard of each package, for which languages PO -files have been submitted to translation coordination, with a +matrix shows the current state of internationalization, as of July +2001. The matrix shows, in regard of each package, for which languages +PO files have been submitted to translation coordination, with a translation percentage of at least 50%. - Ready PO files bg cs da de el en eo es et fi fr gl hr id it - +----------------------------------------------+ - a2ps | [] [] | - bash | [] [] [] [] | - bison | [] [] [] [] | - clisp | [] [] [] [] | - cpio | [] [] [] [] | - diffutils | [] [] [] [] [] [] [] | - enscript | [] [] | - error | [] | - fileutils | [] [] [] [] [] [] [] | - findutils | [] [] [] [] [] [] [] [] | - flex | [] [] [] | - gawk | | - gcal | | - gcc | [] | - gettext | [] [] [] [] [] [] [] [] [] | - gnupg | [] [] [] [] [] | - grep | [] [] [] | - hello | [] [] [] [] [] [] [] [] [] | - id-utils | [] [] | - indent | [] [] [] [] [] | - libc | [] [] [] [] [] [] [] [] | - lilypond | | - lynx | [] [] [] | - m4 | [] [] [] [] [] [] [] | - make | [] [] [] [] | - parted | [] [] | - ptx | [] [] [] [] [] [] [] | - python | | - recode | [] [] [] [] [] [] [] [] | - sed | [] [] [] [] [] [] [] [] [] | - sh-utils | [] [] [] [] [] [] [] [] [] | - sharutils | [] [] [] [] [] [] [] | - soundtracker | | - sp | | - tar | [] [] [] [] [] [] [] [] | - texinfo | [] [] [] [] | - textutils | [] [] [] [] [] [] [] | - util-linux | [] | - wdiff | [] [] [] [] [] [] [] | - wget | [] [] [] [] [] [] [] [] [] | - +----------------------------------------------+ - bg cs da de el en eo es et fi fr gl hr id it - 0 14 21 27 10 1 8 20 13 1 28 17 0 9 11 + Ready PO files bg cs da de el en eo es et fi fr gl he hr id it + +-------------------------------------------------+ + a2ps | [] [] | + bash | [] [] [] [] | + bfd | | + binutils | | + bison | [] [] [] [] | + clisp | [] [] [] [] | + cpio | [] [] [] [] [] | + diffutils | [] [] [] [] [] [] [] | + enscript | [] [] | + error | [] [] | + fetchmail | | + fileutils | [] [] [] [] [] [] [] | + findutils | [] [] [] [] [] [] [] [] | + flex | [] [] [] | + freetype | | + gas | | + gawk | [] | + gcal | | + gcc | | + gettext | [] [] [] [] [] [] [] [] [] | + gnupg | [] [] [] [] [] [] | + gprof | | + grep | [] [] [] [] [] [] [] | + hello | [] [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] | + indent | [] [] [] [] [] | + jpilot | [] | + kbd | | + ld | | + libc | [] [] [] [] [] [] [] [] | + lilypond | | + lynx | [] [] [] | + m4 | [] [] [] [] [] [] [] | + make | [] [] [] [] [] | + nano | [] [] | + opcodes | | + parted | [] [] | + ptx | [] [] [] [] [] [] [] | + python | | + recode | [] [] [] [] [] [] [] [] [] | + sed | [] [] [] [] [] [] [] [] [] [] | + sh-utils | [] [] [] [] [] [] [] [] [] | + sharutils | [] [] [] [] [] [] [] | + soundtracker | [] | + sp | | + tar | [] [] [] [] [] [] [] [] | + texinfo | [] [] [] [] [] | + textutils | [] [] [] [] [] [] [] | + util-linux | [] [] | + wdiff | [] [] | + wget | [] [] [] [] [] [] [] [] [] | + +-------------------------------------------------+ + bg cs da de el en eo es et fi fr gl he hr id it + 0 13 23 30 11 1 8 21 13 1 29 22 3 0 8 10 - ja ko lv nl no pl pt pt_BR ru sk sl sv tr zh - +----------------------------------------------+ - a2ps | [] [] [] | 5 - bash | | 4 - bison | [] [] [] | 7 - clisp | [] | 5 - cpio | [] [] [] [] [] | 9 - diffutils | [] [] [] | 10 - enscript | [] [] [] | 5 - error | | 1 - fileutils | [] [] [] [] [] [] [] [] [] | 16 - findutils | [] [] [] [] [] [] | 14 - flex | [] [] [] | 6 - gawk | | 0 - gcal | | 0 - gcc | [] | 2 - gettext | [] [] [] [] [] [] [] [] [] [] | 19 - gnupg | [] [] [] | 8 - grep | | 3 - hello | [] [] [] [] [] [] [] [] | 17 - id-utils | [] [] [] | 5 - indent | [] [] [] [] [] [] [] | 12 - libc | [] [] [] [] [] [] [] | 15 - lilypond | [] | 1 - lynx | [] [] [] [] [] | 8 - m4 | [] [] [] [] [] | 12 - make | [] [] [] [] [] | 9 - parted | [] [] [] | 5 - ptx | [] [] [] [] [] [] | 13 - python | | 0 - recode | [] [] [] | 11 - sed | [] [] [] [] [] [] [] | 16 - sh-utils | [] [] [] [] [] [] [] [] [] [] | 19 - sharutils | [] [] [] [] | 11 - soundtracker | | 0 - sp | | 0 - tar | [] [] [] [] [] [] [] [] | 16 - texinfo | [] [] | 6 - textutils | [] [] [] [] [] [] [] [] | 15 - util-linux | [] | 2 - wdiff | [] [] [] [] [] | 12 - wget | [] [] [] [] [] [] [] [] | 17 - +----------------------------------------------+ - 29 teams ja ko lv nl no pl pt pt_BR ru sk sl sv tr zh - 40 domains 18 8 0 23 6 16 1 15 26 9 9 20 2 3 336 + ja ko lv nl no pl pt pt_BR ru sk sl sv tr uk zh + +-------------------------------------------------+ + a2ps | [] [] [] | 5 + bash | | 4 + bfd | | 0 + binutils | | 0 + bison | [] [] [] | 7 + clisp | [] | 5 + cpio | [] [] [] [] [] | 10 + diffutils | [] [] [] | 10 + enscript | [] [] [] | 5 + error | [] | 3 + fetchmail | | 0 + fileutils | [] [] [] [] [] [] [] [] [] [] | 17 + findutils | [] [] [] [] [] [] [] [] | 16 + flex | [] [] [] | 6 + freetype | | 0 + gas | | 0 + gawk | [] | 2 + gcal | | 0 + gcc | | 0 + gettext | [] [] [] [] [] [] [] [] [] | 18 + gnupg | [] [] [] [] | 10 + gprof | | 0 + grep | [] [] [] | 10 + hello | [] [] [] [] [] [] [] [] [] [] [] | 21 + id-utils | [] [] [] | 6 + indent | [] [] [] [] [] [] [] | 12 + jpilot | | 1 + kbd | [] | 1 + ld | | 0 + libc | [] [] [] [] [] [] [] [] [] | 17 + lilypond | [] [] | 2 + lynx | [] [] [] [] [] | 8 + m4 | [] [] [] [] [] | 12 + make | [] [] [] [] [] [] [] | 12 + nano | [] | 3 + opcodes | | 0 + parted | [] [] [] | 5 + ptx | [] [] [] [] [] [] [] | 14 + python | | 0 + recode | [] [] [] [] | 13 + sed | [] [] [] [] [] [] [] [] | 18 + sh-utils | [] [] [] [] [] [] [] [] [] [] [] | 20 + sharutils | [] [] [] [] | 11 + soundtracker | | 1 + sp | | 0 + tar | [] [] [] [] [] [] [] [] [] | 17 + texinfo | [] [] | 7 + textutils | [] [] [] [] [] [] [] [] | 15 + util-linux | [] [] | 4 + wdiff | [] [] [] | 5 + wget | [] [] [] [] [] [] [] | 16 + +-------------------------------------------------+ + 31 teams ja ko lv nl no pl pt pt_BR ru sk sl sv tr uk zh + 51 domains 17 9 1 23 6 17 1 13 26 9 11 20 19 2 2 369 Some counters in the preceding matrix are higher than the number of visible blocks let us expect. This is because a few extra PO files are @@ -272,7 +294,7 @@ distributed as such by its maintainer. There might be an observable lag between the mere existence a PO file and its wide availability in a distribution. - If May 2001 seems to be old, you may fetch a more recent copy of + If July 2001 seems to be old, you may fetch a more recent copy of this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date matrix with full percentage details can be found at `http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. @@ -282,13 +304,14 @@ Using `gettext' in new packages If you are writing a freely available program and want to internationalize it you are welcome to use GNU `gettext' in your -package. Of course the GNU Public License applies to your sources from -then if you include `gettext' directly in your distribution on but -since you are writing free software anyway this is no restriction. - - Once the sources are change appropriately and the setup can handle to -use of `gettext' the only thing missing are the translations. The Free -Translation Project is also available for packages which are not +package. Of course the GNU General Public License applies to your +sources from then on if you include `gettext' directly in your +distribution but since you are writing free software anyway this is no +restriction. + + Once the sources are changed appropriately and the setup can handle +to use of `gettext' the only thing missing are the translations. The +Free Translation Project is also available for packages which are not developed inside the GNU project. Therefore the information given above applies also for every other Free Software Project. Contact `translation@iro.umontreal.ca' to make the `.pot' files available to diff --git a/ChangeLog b/ChangeLog index e789dde8f..23cb8efde 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2001-08-27 + + * merged the color label feature from the claws branch (thanks to + Satoshi Nagayasu and Alfons Hoogervoost). + * src/colorlabel.[ch]: new. Renamed from labelcolors.[ch]. + Renamed labelcolors_*() to colorlabel_*(). + * src/summaryview.[ch]: added color label support. + * src/procmsg.h: added color label flags to the permanent flags. + * updated to gettext 0.10.39. + +2001-08-27 + + * src/account.c: account_clist_set_row(): fixed a bug that failed + to compile if SSL was not enabled. + +2001-08-26 + + * merged the SSL support from the claws branch (thanks to Christoph + Hohmann). + * src/ssl.[ch]: new. + * src/socket.[ch]: added ssl_read(), ssl_write(), ssl_gets(), and + ssl_getline(). + sock_close(): call ssl_done_socket() if SSL is active. + * src/md5.[ch]: removed MD5_CTX typedef and use MD5_CONTEXT to + prevent type confliction. + * src/prefs_account.[ch]: added SSL tab, and modified the expression. + * src/esmtp.[ch]: added esmtp_ehlo(), and esmtp_starttls(). + Removed SSL initialization and HELO from esmtp_starttls(). + esmtp_auth(): removed use_smtp_auth from its arguments. + * src/send.c: send_smtp_open(): added SSL support. + * src/smtp.c: smtp_helo(): call esmtp_ehlo() if esmtp is true. + +2001-08-25 + + * src/mimeview.c: mimeview_open_with(): braced '%s' with single + quote. + 2001-08-24 * src/main.c: open new account dialog if no account is set. diff --git a/ChangeLog.claws b/ChangeLog.claws index c2a796607..cd629c69d 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,11 @@ +2001-08-27 [paul] + + * configure.in + change to version 0.5.3claws5 + + * sync with sylpheed 0.5.3cvs9 + src/labelcolors.[ch] renamed to src/colorlabel.[ch] + 2001-08-24 [christoph] * src/filesel.c diff --git a/ChangeLog.jp b/ChangeLog.jp index 19abb2977..f3ed995ce 100644 --- a/ChangeLog.jp +++ b/ChangeLog.jp @@ -1,3 +1,40 @@ +2001-08-27 + + * claws ¥Ö¥é¥ó¥Á¤«¤é¥«¥é¡¼¥é¥Ù¥ëµ¡Ç½¤ò¥Þ¡¼¥¸(Satoshi Nagayasu ¤µ¤ó + ¤È Alfons Hoogervoost ¤µ¤ó thanks)¡£ + * src/colorlabel.[ch]: ¿·µ¬¡£labelcolors.[ch] ¤«¤é̾¾ÎÊѹ¹¡£ + labelcolors_*() ¤ò colorlabel_*() ¤Ë²þ̾¡£ + * src/summaryview.[ch]: ¥«¥é¡¼¥é¥Ù¥ë¤ËÂбþ¡£ + * src/procmsg.h: ±Ê³¥Õ¥é¥°¤Ë¥«¥é¡¼¥é¥Ù¥ë¥Õ¥é¥°¤òÄɲᣠ+ * gettext 0.10.39 ¤Ë¹¹¿·¡£ + +2001-08-27 + + * src/account.c: account_clist_set_row(): SSL ¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤¤ + ¾ì¹ç¤Ë¥³¥ó¥Ñ¥¤¥ë¤Ë¼ºÇÔ¤¹¤ë¥Ð¥°¤ò½¤Àµ¡£ + +2001-08-26 + + * SSL Âбþ¤ò claws ¥Ö¥é¥ó¥Á¤«¤é¥Þ¡¼¥¸(Christoph Hohmann ¤µ¤ó thanks)¡£ + * src/ssl.[ch]: ¿·µ¬¡£ + * src/socket.[ch]: ssl_read(), ssl_write(), ssl_gets(), ¤½¤·¤Æ + ssl_getline() ¤òÄɲᣠ+ sock_close(): SSL ¤¬Í­¸ú¤Ê¤é ssl_done_socket() ¤ò¸Æ¤Ö¤è¤¦¤Ë¤·¤¿¡£ + * src/md5.[ch]: ·¿¤Î¾×ÆͤòËɤ°¤¿¤á¤Ë MD5_CTX ¤Î typedef ¤òºï½ü¤·¡¢ + MD5_CONTEXT ¤ò»ÈÍѤ¹¤ë¤è¤¦¤Ë¤·¤¿¡£ + * src/prefs_account.[ch]: SSL ¥¿¥Ö¤òÄɲä·¡¢É½¸½¤òÊѹ¹¡£ + * src/esmtp.[ch]: esmtp_ehlo() ¤È esmtp_starttls() ¤òÄɲᣠ+ esmtp_starttls() ¤«¤é SSL ½é´ü²½¤È HELO ¤òºï½ü¡£ + esmtp_auth(): °ú¿ô¤«¤é use_smtp_auth ¤òºï½ü¡£ + * src/send.c: send_smtp_open(): SSL Âбþ¤òÄɲᣠ+ * src/smtp.c: smtp_helo(): esmtp ¤¬¿¿¤Ê¤é esmtp_ehlo() ¤ò¸Æ¤Ö¤è¤¦¤Ë + ¤·¤¿¡£ + +2001-08-25 + + * src/mimeview.c: mimeview_open_with(): '%s' ¤ò¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤Ç + °Ï¤Ã¤¿¡£ + 2001-08-24 * src/main.c: ¥¢¥«¥¦¥ó¥È¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¿·µ¬¥¢¥«¥¦¥ó¥È diff --git a/acconfig.h b/acconfig.h index 3194d263a..25a3dfeaa 100644 --- a/acconfig.h +++ b/acconfig.h @@ -24,7 +24,7 @@ /* Define if we use GPGME to support OpenPGP */ #undef USE_GPGME -/* Define if we use GPGME to support OpenPGP */ +/* Define if you use OpenSSL to support SSL */ #undef USE_SSL /* Define to `unsigned int' if or doesn't define. */ @@ -33,6 +33,7 @@ /* Used to test for a u32 typedef */ #undef HAVE_U32_TYPEDEF + #undef PACKAGE #undef VERSION diff --git a/configure.in b/configure.in index 65767cb0f..7df8fa149 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=5 MICRO_VERSION=3 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws4 +EXTRA_VERSION=claws5 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl diff --git a/intl/ChangeLog b/intl/ChangeLog index df904de37..e62afd415 100644 --- a/intl/ChangeLog +++ b/intl/ChangeLog @@ -1,4 +1,4 @@ -2001-05-23 GNU +2001-07-24 GNU - * Version 0.10.38 released. + * Version 0.10.39 released. diff --git a/intl/config.charset b/intl/config.charset index d6f369558..f4f2611c5 100644 --- a/intl/config.charset +++ b/intl/config.charset @@ -80,10 +80,10 @@ # EUC-KR glibc aix hpux irix osf solaris freebsd yes # EUC-TW glibc aix hpux irix osf solaris # BIG5 glibc aix hpux osf solaris freebsd yes -# BIG5HKSCS glibc +# BIG5-HKSCS glibc # GBK aix osf win32 dos # GB18030 glibc -# SJIS hpux osf solaris freebsd +# SHIFT_JIS hpux osf solaris freebsd yes # JOHAB glibc win32 # TIS-620 glibc aix hpux osf solaris # VISCII glibc yes @@ -174,7 +174,7 @@ case "$os" in echo "eucTW EUC-TW" echo "hp15CN GB2312" #echo "ccdc ?" # what is this? - echo "SJIS SJIS" + echo "SJIS SHIFT_JIS" echo "utf8 UTF-8" ;; irix*) @@ -209,7 +209,7 @@ case "$os" in echo "GBK GBK" echo "KSC5601 CP949" echo "sdeckanji EUC-JP" - echo "SJIS SJIS" + echo "SJIS SHIFT_JIS" echo "TACTIS TIS-620" echo "UTF-8 UTF-8" ;; @@ -230,7 +230,7 @@ case "$os" in echo "cns11643 EUC-TW" echo "5601 EUC-KR" echo "eucJP EUC-JP" - echo "PCK SJIS" + echo "PCK SHIFT_JIS" echo "TIS620.2533 TIS-620" #echo "sun_eu_greek ?" # what is this? echo "UTF-8 UTF-8" @@ -266,8 +266,8 @@ case "$os" in echo "zh_TW.Big5 BIG5" echo "zh_CN.EUC GB2312" echo "ja_JP.EUC EUC-JP" - echo "ja_JP.SJIS SJIS" - echo "ja_JP.Shift_JIS SJIS" + echo "ja_JP.SJIS SHIFT_JIS" + echo "ja_JP.Shift_JIS SHIFT_JIS" echo "ko_KR.EUC EUC-KR" ;; beos*) diff --git a/intl/dcigettext.c b/intl/dcigettext.c index 8456550d0..b7627bf61 100644 --- a/intl/dcigettext.c +++ b/intl/dcigettext.c @@ -517,6 +517,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category) /* We cannot get the current working directory. Don't signal an error but simply return the default string. */ FREE_BLOCKS (block_list); + __libc_rwlock_unlock (_nl_state_lock); __set_errno (saved_errno); return (plural == 0 ? (char *) msgid1 diff --git a/intl/localcharset.c b/intl/localcharset.c index 22e09e410..61f8f3e85 100644 --- a/intl/localcharset.c +++ b/intl/localcharset.c @@ -75,13 +75,13 @@ /* Pointer to the contents of the charset.alias file, if it has already been read, else NULL. Its format is: ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */ -static char * volatile charset_aliases; +static const char * volatile charset_aliases; /* Return a pointer to the contents of the charset.alias file. */ static const char * get_charset_aliases () { - char *cp; + const char *cp; cp = charset_aliases; if (cp == NULL) diff --git a/src/Makefile.am b/src/Makefile.am index aa41e4b28..546278b2d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ sylpheed_SOURCES = \ imageview.c imageview.h \ mimeview.c mimeview.h \ summary_search.c summary_search.h \ + colorlabel.c colorlabel.h \ folder.c folder.h \ procmsg.c procmsg.h \ procheader.c procheader.h \ @@ -54,6 +55,7 @@ sylpheed_SOURCES = \ md5.c md5.h \ rfc822.c rfc822.h \ socket.c socket.h \ + ssl.c ssl.h \ automaton.c automaton.h \ session.c session.h \ smtp.c smtp.h \ @@ -98,8 +100,6 @@ sylpheed_SOURCES = \ editjpilot.c editjpilot.h \ editldap.c editldap.h \ editldap_basedn.c editldap_basedn.h \ - labelcolors.c labelcolors.h \ - ssl.c ssl.h \ gtkspell.c gtkspell.h gtkxtext.h \ template.c template.h \ prefs_templates.c prefs_templates.h \ diff --git a/src/about.c b/src/about.c index efcbf111a..5fdf4eacf 100644 --- a/src/about.c +++ b/src/about.c @@ -147,6 +147,9 @@ static void about_create(void) #if USE_GPGME " GPGME" #endif +#if USE_SSL + " SSL" +#endif #if USE_LDAP " LDAP" #endif diff --git a/src/account.c b/src/account.c index 94bf40ec3..0bf8a40ee 100644 --- a/src/account.c +++ b/src/account.c @@ -711,18 +711,22 @@ static gint account_clist_set_row(PrefsAccount *ac_prefs, gint row) ac_prefs->protocol == A_APOP) && ac_prefs->recv_at_getall ? "*" : ""; text[COL_NAME] = ac_prefs->account_name; -#if !USE_SSL - text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ? "POP3" : - ac_prefs->protocol == A_APOP ? "APOP" : - ac_prefs->protocol == A_IMAP4 ? "IMAP4" : +#if USE_SSL + text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ? + (ac_prefs->ssl_pop ? "POP3 (SSL)" : "POP3") : + ac_prefs->protocol == A_APOP ? + (ac_prefs->ssl_pop ? + "POP3 (APOP, SSL)" : "POP3 (APOP)") : + ac_prefs->protocol == A_IMAP4 ? + (ac_prefs->ssl_imap ? "IMAP4 (SSL)" : "IMAP4") : ac_prefs->protocol == A_LOCAL ? "Local" : - ac_prefs->protocol == A_NNTP ? "NNTP" : ""; + ac_prefs->protocol == A_NNTP ? "NNTP" : ""; #else - text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ? (!ac_prefs->ssl_pop ? "POP3" : "POP3 (SSL)") : - ac_prefs->protocol == A_APOP ? (!ac_prefs->ssl_pop ? "APOP" : "APOP (SSL)") : - ac_prefs->protocol == A_IMAP4 ? (!ac_prefs->ssl_imap ? "IMAP4" : "IMAP4 (SSL)") : + text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ? "POP3" : + ac_prefs->protocol == A_APOP ? "POP3 (APOP)" : + ac_prefs->protocol == A_IMAP4 ? "IMAP4" : ac_prefs->protocol == A_LOCAL ? "Local" : - ac_prefs->protocol == A_NNTP ? "NNTP" : ""; + ac_prefs->protocol == A_NNTP ? "NNTP" : ""; #endif text[COL_SERVER] = ac_prefs->protocol == A_NNTP ? ac_prefs->nntp_server : ac_prefs->recv_server; diff --git a/src/esmtp.c b/src/esmtp.c index 529bef2f1..5c8a9c000 100644 --- a/src/esmtp.c +++ b/src/esmtp.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999,2000 Hiroyuki Yamamoto + * Copyright (C) 1999-2001 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,41 +33,49 @@ static gint verbose = 1; static gchar esmtp_response[MSGBUFSIZE]; -gint esmtp_auth_cram_md5(SockInfo *sock) +gint esmtp_ehlo(SockInfo *sock, const gchar *hostname) { - gchar buf[MSGBUFSIZE]; + sock_printf(sock, "EHLO %s\r\n", hostname); + if (verbose) + log_print("ESMTP> EHLO %s\n", hostname); - g_snprintf(buf, sizeof(buf), "AUTH CRAM-MD5"); - sock_printf(sock, "%s\r\n", buf); + return esmtp_ok(sock); +} +gint esmtp_starttls(SockInfo *sock) +{ + sock_printf(sock, "STARTTLS\r\n"); if (verbose) - log_print("ESMTP> %s\n", buf); + log_print("ESMTP> STARTTLS\n"); return esmtp_ok(sock); } -gint esmtp_auth_login(SockInfo *sock) +gint esmtp_auth_cram_md5(SockInfo *sock) { - gchar buf[MSGBUFSIZE]; + sock_printf(sock, "AUTH CRAM-MD5\r\n"); + if (verbose) + log_print("ESMTP> AUTH CRAM-MD5\n"); - g_snprintf(buf, sizeof(buf), "AUTH LOGIN"); - sock_printf(sock, "%s\r\n", buf); + return esmtp_ok(sock); +} +gint esmtp_auth_login(SockInfo *sock) +{ + sock_printf(sock, "AUTH LOGIN\r\n"); if (verbose) - log_print("ESMTP> %s\n", buf); + log_print("ESMTP> AUTH LOGIN\n"); return esmtp_ok(sock); } gint esmtp_auth(SockInfo *sock, SMTPAuthType authtype, - const gchar *userid, const gchar *passwd, - gboolean use_smtp_auth) + const gchar *userid, const gchar *passwd) { gchar buf[MSGBUFSIZE]; guchar hexdigest[33]; gchar *challenge, *response, *response64; gint challengelen; - /* const gchar delimiters[]=" "; */ gchar *token; switch (authtype) { diff --git a/src/esmtp.h b/src/esmtp.h index 95bf8b810..cb9073973 100644 --- a/src/esmtp.h +++ b/src/esmtp.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999,2000 Hiroyuki Yamamoto + * Copyright (C) 1999-2001 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,8 +20,16 @@ #ifndef __ESMTP_H__ #define __ESMTP_H__ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include + #include "socket.h" +#if USE_SSL +# include "ssl.h" +#endif typedef enum { @@ -30,11 +38,12 @@ typedef enum SMTPAUTH_DIGEST_MD5 = 3 } SMTPAuthType; +gint esmtp_ehlo(SockInfo *sock, const gchar *hostname); +gint esmtp_starttls(SockInfo *sock); gint esmtp_auth_login(SockInfo *sock); gint esmtp_auth_cram_md5(SockInfo *sock); gint esmtp_auth(SockInfo *sock, SMTPAuthType authtype, - const gchar *userid, const gchar *passwd, - gboolean use_smtp_auth); + const gchar *userid, const gchar *passwd); gint esmtp_ok(SockInfo *sock); #endif /* __ESMTP_H__ */ diff --git a/src/filtering.c b/src/filtering.c index 7b3e39ab6..ccb8ffee6 100644 --- a/src/filtering.c +++ b/src/filtering.c @@ -880,7 +880,7 @@ static gboolean filter_incoming_perform_actions(FolderItem *default_folder, break; case MATCHING_ACTION_COLOR: - MSG_SET_LABEL_VALUE(markflags, ma_tail->action->labelcolor); + MSG_SET_COLORLABEL_VALUE(markflags, ma_tail->action->labelcolor); break; /* UNCONTINUABLE */ diff --git a/src/imap.c b/src/imap.c index b8838f72f..e6e52a34e 100644 --- a/src/imap.c +++ b/src/imap.c @@ -32,6 +32,7 @@ #include "intl.h" #include "imap.h" #include "socket.h" +#include "ssl.h" #include "recv.h" #include "procmsg.h" #include "procheader.h" @@ -41,7 +42,6 @@ #include "codeconv.h" #include "utils.h" #include "inputdialog.h" -#include "ssl.h" #define IMAP4_PORT 143 #if USE_SSL @@ -82,15 +82,15 @@ static GSList *imap_delete_cached_messages (GSList *mlist, guint32 last_uid); static void imap_delete_all_cached_messages (FolderItem *item); -#if !USE_SSL +#if USE_SSL static SockInfo *imap_open (const gchar *server, gushort port, - gchar *buf); + gchar *buf, + gboolean use_ssl); #else static SockInfo *imap_open (const gchar *server, gushort port, - gchar *buf, - gboolean use_ssl); + gchar *buf); #endif static gint imap_set_message_flags (IMAPSession *session, @@ -230,25 +230,25 @@ static IMAPSession *imap_session_get(Folder *folder) g_return_val_if_fail(folder->type == F_IMAP, NULL); g_return_val_if_fail(folder->account != NULL, NULL); -#if !USE_SSL +#if USE_SSL port = folder->account->set_imapport ? folder->account->imapport - : IMAP4_PORT; + : folder->account->ssl_imap ? IMAPS_PORT : IMAP4_PORT; #else port = folder->account->set_imapport ? folder->account->imapport - : (folder->account->ssl_imap ? IMAPS_PORT : IMAP4_PORT); + : IMAP4_PORT; #endif if (!rfolder->session) { rfolder->session = -#if !USE_SSL +#if USE_SSL imap_session_new(folder->account->recv_server, port, folder->account->userid, - folder->account->passwd); + folder->account->passwd, + folder->account->ssl_imap); #else imap_session_new(folder->account->recv_server, port, folder->account->userid, - folder->account->passwd, - folder->account->ssl_imap); + folder->account->passwd); #endif if (rfolder->session) imap_parse_namespace(IMAP_SESSION(rfolder->session), @@ -263,15 +263,15 @@ static IMAPSession *imap_session_get(Folder *folder) folder->account->recv_server, port); session_destroy(rfolder->session); rfolder->session = -#if !USE_SSL +#if USE_SSL imap_session_new(folder->account->recv_server, port, folder->account->userid, - folder->account->passwd); + folder->account->passwd, + folder->account->ssl_imap); #else imap_session_new(folder->account->recv_server, port, folder->account->userid, - folder->account->passwd, - folder->account->ssl_imap); + folder->account->passwd); #endif if (rfolder->session) imap_parse_namespace(IMAP_SESSION(rfolder->session), @@ -295,13 +295,13 @@ static gchar *imap_query_password(const gchar *server, const gchar *user) return pass; } -#if !USE_SSL -Session *imap_session_new(const gchar *server, gushort port, - const gchar *user, const gchar *pass) -#else +#if USE_SSL Session *imap_session_new(const gchar *server, gushort port, const gchar *user, const gchar *pass, gboolean use_ssl) +#else +Session *imap_session_new(const gchar *server, gushort port, + const gchar *user, const gchar *pass) #endif { gchar buf[IMAPBUFSIZE]; @@ -323,10 +323,10 @@ Session *imap_session_new(const gchar *server, gushort port, log_message(_("creating IMAP4 connection to %s:%d ...\n"), server, port); -#if !USE_SSL - if ((imap_sock = imap_open(server, port, buf)) == NULL) -#else +#if USE_SSL if ((imap_sock = imap_open(server, port, buf, use_ssl)) == NULL) +#else + if ((imap_sock = imap_open(server, port, buf)) == NULL) #endif return NULL; if (imap_cmd_login(imap_sock, user, pass) != IMAP_SUCCESS) { @@ -351,9 +351,6 @@ Session *imap_session_new(const gchar *server, gushort port, void imap_session_destroy(IMAPSession *session) { -#if USE_SSL - ssl_done_socket(SESSION(session)->sock); -#endif sock_close(SESSION(session)->sock); SESSION(session)->sock = NULL; @@ -1279,10 +1276,11 @@ static void imap_delete_all_cached_messages(FolderItem *item) debug_print(_("done.\n")); } -#if !USE_SSL -static SockInfo *imap_open(const gchar *server, gushort port, gchar *buf) +#if USE_SSL +static SockInfo *imap_open(const gchar *server, gushort port, gchar *buf, + gboolean use_ssl) #else -static SockInfo *imap_open(const gchar *server, gushort port, gchar *buf, gboolean use_ssl) +static SockInfo *imap_open(const gchar *server, gushort port, gchar *buf) #endif { SockInfo *sock; @@ -1294,7 +1292,7 @@ static SockInfo *imap_open(const gchar *server, gushort port, gchar *buf, gboole } #if USE_SSL - if(use_ssl && !ssl_init_socket(sock)) { + if (use_ssl && !ssl_init_socket(sock)) { sock_close(sock); return NULL; } diff --git a/src/inc.c b/src/inc.c index 4ce3325ba..99cf34779 100644 --- a/src/inc.c +++ b/src/inc.c @@ -48,6 +48,7 @@ #include "account.h" #include "procmsg.h" #include "socket.h" +#include "ssl.h" #include "pop.h" #include "recv.h" #include "mbox.h" @@ -431,7 +432,7 @@ static gint inc_start(IncProgressDialog *inc_dialog) inc_progress_dialog_clear(inc_dialog); - gtk_clist_moveto(clist, num, 0, 1.0, 0.0); + gtk_clist_moveto(clist, num, -1, 1.0, 0.0); pop3_state->user = g_strdup(pop3_state->ac_prefs->userid); if (pop3_state->ac_prefs->passwd) @@ -561,7 +562,6 @@ static gint inc_start(IncProgressDialog *inc_dialog) return new_msgs; } - static IncState inc_pop3_session_do(IncSession *session) { Pop3State *pop3_state = session->pop3_state; @@ -614,7 +614,8 @@ static IncState inc_pop3_session_do(IncSession *session) server = pop3_state->ac_prefs->recv_server; #if USE_SSL port = pop3_state->ac_prefs->set_popport ? - pop3_state->ac_prefs->popport : (pop3_state->ac_prefs->ssl_pop ? 995 : 110); + pop3_state->ac_prefs->popport : + pop3_state->ac_prefs->ssl_pop ? 995 : 110; #else port = pop3_state->ac_prefs->set_popport ? pop3_state->ac_prefs->popport : 110; @@ -645,28 +646,22 @@ static IncState inc_pop3_session_do(IncSession *session) } pop3_automaton_terminate(NULL, atm); automaton_destroy(atm); + return INC_CONNECT_ERROR; + } +#if USE_SSL + if (pop3_state->ac_prefs->ssl_pop && !ssl_init_socket(sockinfo)) { + pop3_automaton_terminate(NULL, atm); + automaton_destroy(atm); return INC_CONNECT_ERROR; } +#endif /* :WK: Hmmm, with the later sock_gdk_input, we have 2 references * to the sock structure - implement a reference counter?? */ pop3_state->sockinfo = sockinfo; atm->help_sock = sockinfo; -#ifdef USE_SSL - if(pop3_state->ac_prefs->ssl_pop) { - if(!ssl_init_socket(sockinfo)) { - pop3_automaton_terminate(NULL, atm); - automaton_destroy(atm); - - return INC_CONNECT_ERROR; - } - } else { - sockinfo->ssl = NULL; - } -#endif - log_verbosity_set(TRUE); recv_set_ui_func(inc_pop3_recv_func, session); @@ -685,13 +680,7 @@ static IncState inc_pop3_session_do(IncSession *session) recv_set_ui_func(NULL, NULL); #if USE_THREADS -/* - pthread_join(sockinfo->connect_thr, NULL); -*/ -#endif - -#if USE_SSL - ssl_done_socket(sockinfo); + //pthread_join(sockinfo->connect_thr, NULL); #endif automaton_destroy(atm); @@ -862,7 +851,7 @@ void inc_progress_update(Pop3State *state, Pop3Phase phase) case POP3_GETAUTH_PASS_RECV: case POP3_GETAUTH_APOP_SEND: case POP3_GETAUTH_APOP_RECV: - progress_dialog_set_label(dialog, _("Authorizing...")); + progress_dialog_set_label(dialog, _("Authenticating...")); break; case POP3_GETRANGE_STAT_SEND: case POP3_GETRANGE_STAT_RECV: diff --git a/src/main.c b/src/main.c index ae08074e2..04367abab 100644 --- a/src/main.c +++ b/src/main.c @@ -49,10 +49,6 @@ # include #endif -#if USE_SSL -# include "ssl.h" -#endif - #include "intl.h" #include "main.h" #include "mainwindow.h" @@ -79,6 +75,9 @@ #if USE_GPGME # include "rfc2015.h" #endif +#if USE_SSL +# include "ssl.h" +#endif gchar *prog_version; gchar *startup_dir; @@ -160,6 +159,10 @@ int main(int argc, char *argv[]) gtk_widget_push_colormap(gdk_imlib_get_colormap()); #endif +#if USE_SSL + ssl_init(); +#endif + srandom((gint)time(NULL)); /* parse gtkrc files */ @@ -237,10 +240,6 @@ int main(int argc, char *argv[]) gpgme_register_idle(idle_function_for_gpgme); #endif -#if USE_SSL - ssl_init(); -#endif - prefs_common_save_config(); prefs_filter_read_config(); prefs_filter_write_config(); @@ -294,10 +293,6 @@ int main(int argc, char *argv[]) gtk_main(); -#if USE_SSL - ssl_done(); -#endif - return 0; } @@ -404,6 +399,10 @@ void app_will_exit(GtkWidget *widget, gpointer data) filename = get_socket_name(); unlink(filename); +#if USE_SSL + ssl_done(); +#endif + gtk_main_quit(); } diff --git a/src/md5.c b/src/md5.c index fcc8f9687..53b9711d2 100644 --- a/src/md5.c +++ b/src/md5.c @@ -333,7 +333,7 @@ void md5_hex_digest(char *hexdigest, const unsigned char *s) { int i; - MD5_CTX_syl context; + MD5_CONTEXT context; unsigned char digest[16]; md5_init(&context); @@ -355,7 +355,7 @@ md5_hmac(unsigned char *digest, const unsigned char* text, int text_len, const unsigned char* key, int key_len) { - MD5_CTX_syl context; + MD5_CONTEXT context; unsigned char k_ipad[64]; /* inner padding - * key XORd with ipad */ @@ -370,7 +370,7 @@ md5_hmac(unsigned char *digest, memset(k_opad, 0, sizeof k_opad); if (key_len > 64) { /* if key is longer than 64 bytes reset it to key=MD5(key) */ - MD5_CTX_syl tctx; + MD5_CONTEXT tctx; md5_init(&tctx); md5_update(&tctx, key, key_len); diff --git a/src/md5.h b/src/md5.h index a3783dad2..84894b2c2 100644 --- a/src/md5.h +++ b/src/md5.h @@ -32,8 +32,6 @@ typedef struct { /* Hmm, should be private */ int finalized; } MD5_CONTEXT; -typedef MD5_CONTEXT MD5_CTX_syl; - void md5_init(MD5_CONTEXT *ctx); void md5_update(MD5_CONTEXT *hd, const unsigned char *inbuf, size_t inlen); void md5_final(unsigned char *digest, MD5_CONTEXT *ctx); diff --git a/src/mimeview.c b/src/mimeview.c index b12254193..0ed9ab844 100644 --- a/src/mimeview.c +++ b/src/mimeview.c @@ -777,7 +777,7 @@ static void mimeview_open_with(MimeView *mimeview) (_("Open with"), _("Enter the command line to open file:\n" "(`%s' will be replaced with file name)"), - "gedit \"%s\""); + "gedit '%s'"); if (cmd) { mimeview_view_file(filename, partinfo, cmd); g_free(cmd); diff --git a/src/prefs_account.c b/src/prefs_account.c index 2218a66b4..6ae61d4b5 100644 --- a/src/prefs_account.c +++ b/src/prefs_account.c @@ -126,9 +126,11 @@ static struct Privacy { #if USE_SSL static struct SSLPrefs { + GtkWidget *receive_frame; GtkWidget *pop_chkbtn; GtkWidget *imap_chkbtn; + GtkWidget *send_frame; GtkWidget *smtp_nossl_radiobtn; GtkWidget *smtp_ssltunnel_radiobtn; GtkWidget *smtp_sslstarttls_radiobtn; @@ -159,7 +161,7 @@ static void prefs_account_protocol_activated (GtkMenuItem *menuitem); #if USE_GPGME || USE_SSL static void prefs_account_enum_set_data_from_radiobtn (PrefParam *pparam); static void prefs_account_enum_set_radiobtn (PrefParam *pparam); -#endif /* USE_GPGME */ +#endif /* USE_GPGME || USE_SSL */ static void prefs_account_nntpauth_toggled(GtkToggleButton *button, gpointer user_data); @@ -302,19 +304,15 @@ static PrefParam param[] = { #endif /* USE_GPGME */ #if USE_SSL - /* SSL Config */ - {"ssl_smtp", "FALSE", &tmp_ac_prefs.ssl_smtp, P_ENUM, + /* SSL */ + {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM, &ssl.smtp_nossl_radiobtn, prefs_account_enum_set_data_from_radiobtn, prefs_account_enum_set_radiobtn}, - {"ssl_pop", "FALSE", &tmp_ac_prefs.ssl_pop, P_BOOL, - &ssl.pop_chkbtn, - prefs_set_data_from_toggle, prefs_set_toggle}, - + &ssl.pop_chkbtn, prefs_set_data_from_toggle, prefs_set_toggle}, {"ssl_imap", "FALSE", &tmp_ac_prefs.ssl_imap, P_BOOL, - &ssl.imap_chkbtn, - prefs_set_data_from_toggle, prefs_set_toggle}, + &ssl.imap_chkbtn, prefs_set_data_from_toggle, prefs_set_toggle}, #endif /* USE_SSL */ /* Advanced */ @@ -596,7 +594,7 @@ static void prefs_account_create(void) #if USE_SSL prefs_account_ssl_create(); SET_NOTEBOOK_LABEL(dialog.notebook, _("SSL"), page++); -#endif /* USE_GPGME */ +#endif /* USE_SSL */ prefs_account_advanced_create(); SET_NOTEBOOK_LABEL(dialog.notebook, _("Advanced"), page++); @@ -1245,13 +1243,11 @@ static void prefs_account_ssl_create(void) GtkWidget *smtp_ssltunnel_radiobtn; GtkWidget *smtp_sslstarttls_radiobtn; - /* Vertial Box */ vbox1 = gtk_vbox_new (FALSE, VSPACING); gtk_widget_show (vbox1); gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1); gtk_container_set_border_width (GTK_CONTAINER (vbox1), BOX_BORDER); - /* Receive Options */ PACK_FRAME (vbox1, receive_frame, _("Receive")); vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW); @@ -1259,19 +1255,20 @@ static void prefs_account_ssl_create(void) gtk_container_add (GTK_CONTAINER (receive_frame), vbox2); gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8); - PACK_CHECK_BUTTON (vbox2, pop_chkbtn, _("Use SSL tunnel to connect to POP server")); - PACK_CHECK_BUTTON (vbox2, imap_chkbtn, _("Use SSL tunnel to connect to IMAP server")); + PACK_CHECK_BUTTON (vbox2, pop_chkbtn, + _("Use SSL for POP3 connection")); + PACK_CHECK_BUTTON (vbox2, imap_chkbtn, + _("Use SSL for IMAP4 connection")); - /* Send Options */ - PACK_FRAME (vbox1, send_frame, _("Send")); + PACK_FRAME (vbox1, send_frame, _("Send (SMTP)")); vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW); gtk_widget_show (vbox3); gtk_container_add (GTK_CONTAINER (send_frame), vbox3); gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8); - smtp_nossl_radiobtn = gtk_radio_button_new_with_label - (NULL, _("No SSL for SMTP")); + smtp_nossl_radiobtn = + gtk_radio_button_new_with_label(NULL, _("Don't use SSL")); gtk_widget_show (smtp_nossl_radiobtn); gtk_box_pack_start (GTK_BOX (vbox3), smtp_nossl_radiobtn, FALSE, FALSE, 0); @@ -1280,7 +1277,7 @@ static void prefs_account_ssl_create(void) smtp_ssltunnel_radiobtn = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (smtp_nossl_radiobtn), - _("Use SSL tunnel to connect to SMTP server")); + _("Use SSL for SMTP connection")); gtk_widget_show (smtp_ssltunnel_radiobtn); gtk_box_pack_start (GTK_BOX (vbox3), smtp_ssltunnel_radiobtn, FALSE, FALSE, 0); @@ -1289,17 +1286,20 @@ static void prefs_account_ssl_create(void) smtp_sslstarttls_radiobtn = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (smtp_nossl_radiobtn), - _("Use STARTTLS command to start SMTP SSL session")); + _("Use STARTTLS command to start SSL session")); gtk_widget_show (smtp_sslstarttls_radiobtn); gtk_box_pack_start (GTK_BOX (vbox3), smtp_sslstarttls_radiobtn, FALSE, FALSE, 0); gtk_object_set_user_data (GTK_OBJECT (smtp_sslstarttls_radiobtn), GINT_TO_POINTER (SSL_SMTP_STARTTLS)); - ssl.pop_chkbtn = pop_chkbtn; - ssl.imap_chkbtn = imap_chkbtn; - ssl.smtp_nossl_radiobtn = smtp_nossl_radiobtn; - ssl.smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn; + ssl.receive_frame = receive_frame; + ssl.pop_chkbtn = pop_chkbtn; + ssl.imap_chkbtn = imap_chkbtn; + + ssl.send_frame = send_frame; + ssl.smtp_nossl_radiobtn = smtp_nossl_radiobtn; + ssl.smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn; ssl.smtp_sslstarttls_radiobtn = smtp_sslstarttls_radiobtn; } #endif /* USE_SSL */ @@ -1632,14 +1632,15 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem) (GTK_TOGGLE_BUTTON(basic.nntpauth_chkbtn), NULL); gtk_widget_set_sensitive(receive.pop3_frame, FALSE); gtk_widget_set_sensitive(receive.imap_frame, FALSE); - gtk_widget_hide(advanced.popport_hbox); - gtk_widget_hide(advanced.imapport_hbox); - gtk_widget_show(advanced.nntpport_hbox); - #if USE_SSL + gtk_widget_set_sensitive(ssl.receive_frame, FALSE); gtk_widget_set_sensitive(ssl.pop_chkbtn, FALSE); gtk_widget_set_sensitive(ssl.imap_chkbtn, FALSE); + gtk_widget_set_sensitive(ssl.send_frame, FALSE); #endif + gtk_widget_hide(advanced.popport_hbox); + gtk_widget_hide(advanced.imapport_hbox); + gtk_widget_show(advanced.nntpport_hbox); break; case A_LOCAL: gtk_widget_set_sensitive(basic.inbox_label, TRUE); @@ -1684,16 +1685,18 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem) gtk_widget_set_sensitive(basic.pass_entry, TRUE); gtk_widget_set_sensitive(receive.pop3_frame, FALSE); gtk_widget_set_sensitive(receive.imap_frame, FALSE); - gtk_widget_hide(advanced.popport_hbox); - gtk_widget_hide(advanced.imapport_hbox); - gtk_widget_hide(advanced.nntpport_hbox); prefs_account_mailcmd_toggled (GTK_TOGGLE_BUTTON(basic.mailcmd_chkbtn), NULL); #if USE_SSL + gtk_widget_set_sensitive(ssl.receive_frame, FALSE); gtk_widget_set_sensitive(ssl.pop_chkbtn, FALSE); gtk_widget_set_sensitive(ssl.imap_chkbtn, FALSE); + gtk_widget_set_sensitive(ssl.send_frame, TRUE); #endif + gtk_widget_hide(advanced.popport_hbox); + gtk_widget_hide(advanced.imapport_hbox); + gtk_widget_hide(advanced.nntpport_hbox); break; case A_IMAP4: gtk_widget_set_sensitive(basic.inbox_label, FALSE); @@ -1742,14 +1745,16 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem) gtk_widget_set_sensitive(receive.imap_frame, TRUE); gtk_widget_set_sensitive(basic.smtpserv_entry, TRUE); gtk_widget_set_sensitive(basic.smtpserv_label, TRUE); - gtk_widget_hide(advanced.popport_hbox); - gtk_widget_show(advanced.imapport_hbox); - gtk_widget_hide(advanced.nntpport_hbox); #if USE_SSL + gtk_widget_set_sensitive(ssl.receive_frame, TRUE); gtk_widget_set_sensitive(ssl.pop_chkbtn, FALSE); gtk_widget_set_sensitive(ssl.imap_chkbtn, TRUE); + gtk_widget_set_sensitive(ssl.send_frame, TRUE); #endif + gtk_widget_hide(advanced.popport_hbox); + gtk_widget_show(advanced.imapport_hbox); + gtk_widget_hide(advanced.nntpport_hbox); break; case A_POP3: default: @@ -1799,14 +1804,16 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem) gtk_widget_set_sensitive(receive.imap_frame, FALSE); gtk_widget_set_sensitive(basic.smtpserv_entry, TRUE); gtk_widget_set_sensitive(basic.smtpserv_label, TRUE); - gtk_widget_show(advanced.popport_hbox); - gtk_widget_hide(advanced.imapport_hbox); - gtk_widget_hide(advanced.nntpport_hbox); #if USE_SSL + gtk_widget_set_sensitive(ssl.receive_frame, TRUE); gtk_widget_set_sensitive(ssl.pop_chkbtn, TRUE); gtk_widget_set_sensitive(ssl.imap_chkbtn, FALSE); + gtk_widget_set_sensitive(ssl.send_frame, TRUE); #endif + gtk_widget_show(advanced.popport_hbox); + gtk_widget_hide(advanced.imapport_hbox); + gtk_widget_hide(advanced.nntpport_hbox); break; } diff --git a/src/prefs_account.h b/src/prefs_account.h index 11f0f0105..a60e0937e 100644 --- a/src/prefs_account.h +++ b/src/prefs_account.h @@ -78,6 +78,14 @@ struct _PrefsAccount gboolean use_mail_command; gchar * mail_command; +#if USE_SSL + /* SSL */ + gboolean ssl_pop; + gboolean ssl_imap; + SSLSMTPType ssl_smtp; +#endif /* USE_SSL */ + + /* Temporarily preserved password */ gchar *tmp_pass; @@ -113,13 +121,6 @@ struct _PrefsAccount gchar *sign_key_id; #endif /* USE_GPGME */ -#if USE_SSL - /* SSL Config */ - gboolean ssl_pop; - gboolean ssl_imap; - SSLSMTPType ssl_smtp; -#endif /* USE_SSL */ - /* Advanced */ gboolean set_smtpport; gushort smtpport; diff --git a/src/prefs_filtering.c b/src/prefs_filtering.c index ea9996cab..ae41f3e59 100644 --- a/src/prefs_filtering.c +++ b/src/prefs_filtering.c @@ -474,8 +474,8 @@ static void prefs_filtering_create(void) gtk_box_pack_start (GTK_BOX (hbox1), dest_entry, TRUE, TRUE, 0); color_optmenu = gtk_option_menu_new(); - gtk_option_menu_set_menu(GTK_OPTION_MENU(color_optmenu), - labelcolors_create_color_menu()); + gtk_option_menu_set_menu(GTK_OPTION_MENU(color_optmenu), + colorlabel_create_color_menu()); // gtk_widget_set_usize(color_optmenu, -1, -1); gtk_box_pack_start(GTK_BOX(hbox1), color_optmenu, TRUE, TRUE, 0); @@ -762,7 +762,7 @@ static FilteringProp * prefs_filtering_dialog_to_filtering(void) } break; case ACTION_COLOR: - labelcolor = labelcolors_get_color_menu_active_item( + labelcolor = colorlabel_get_color_menu_active_item( gtk_option_menu_get_menu(GTK_OPTION_MENU(filtering.color_optmenu))); destination = NULL; break; diff --git a/src/procmsg.h b/src/procmsg.h index 60795bda0..8097cfa95 100644 --- a/src/procmsg.h +++ b/src/procmsg.h @@ -42,28 +42,27 @@ typedef enum MSG_REALLY_DELETED = 1 << 6, /* mbox stuff */ -#define MSG_LABEL_SBIT (7) /* start bit message label */ -#define MAKE_MSG_LABEL(h, m, l) (((h) << (MSG_LABEL_SBIT+2)) | \ - ((m) << (MSG_LABEL_SBIT+1)) | \ - ((l) << (MSG_LABEL_SBIT+0))) - - MSG_LABEL = MAKE_MSG_LABEL(1, 1, 1), - MSG_LABEL_NONE = MAKE_MSG_LABEL(0, 0, 0), - MSG_LABEL_1 = MAKE_MSG_LABEL(0, 0, 1), - MSG_LABEL_2 = MAKE_MSG_LABEL(0, 1, 0), - MSG_LABEL_3 = MAKE_MSG_LABEL(0, 1, 1), - MSG_LABEL_4 = MAKE_MSG_LABEL(1, 0, 0), - MSG_LABEL_5 = MAKE_MSG_LABEL(1, 0, 1), - MSG_LABEL_6 = MAKE_MSG_LABEL(1, 1, 0), - MSG_LABEL_7 = MAKE_MSG_LABEL(1, 1, 1), - -#define MSG_LABEL_ORANGE (MSG_LABEL_1) -#define MSG_LABEL_RED (MSG_LABEL_2) -#define MSG_LABEL_PINK (MSG_LABEL_3) -#define MSG_LABEL_SKYBLUE (MSG_LABEL_4) -#define MSG_LABEL_BLUE (MSG_LABEL_5) -#define MSG_LABEL_GREEN (MSG_LABEL_6) -#define MSG_LABEL_BROWN (MSG_LABEL_7) +#define MSG_CLABEL_SBIT (7) /* start bit of color label */ +#define MAKE_MSG_CLABEL(h, m, l) (((h) << (MSG_CLABEL_SBIT + 2)) | \ + ((m) << (MSG_CLABEL_SBIT + 1)) | \ + ((l) << (MSG_CLABEL_SBIT + 0))) + + MSG_CLABEL_NONE = MAKE_MSG_CLABEL(0, 0, 0), + MSG_CLABEL_1 = MAKE_MSG_CLABEL(0, 0, 1), + MSG_CLABEL_2 = MAKE_MSG_CLABEL(0, 1, 0), + MSG_CLABEL_3 = MAKE_MSG_CLABEL(0, 1, 1), + MSG_CLABEL_4 = MAKE_MSG_CLABEL(1, 0, 0), + MSG_CLABEL_5 = MAKE_MSG_CLABEL(1, 0, 1), + MSG_CLABEL_6 = MAKE_MSG_CLABEL(1, 1, 0), + MSG_CLABEL_7 = MAKE_MSG_CLABEL(1, 1, 1), + +#define MSG_CLABEL_ORANGE MSG_CLABEL_1 +#define MSG_CLABEL_RED MSG_CLABEL_2 +#define MSG_CLABEL_PINK MSG_CLABEL_3 +#define MSG_CLABEL_SKYBLUE MSG_CLABEL_4 +#define MSG_CLABEL_BLUE MSG_CLABEL_5 +#define MSG_CLABEL_GREEN MSG_CLABEL_6 +#define MSG_CLABEL_BROWN MSG_CLABEL_7 MSG_IGNORE_THREAD = 1 << 10, /* ignore threads */ @@ -72,11 +71,13 @@ typedef enum MSG_RESERVED_MAIN = 1 << 31 /* for sylpheed-main */ } MsgPermFlags; +#define MSG_CLABEL_FLAG_MASK (MSG_CLABEL_7) + typedef enum { MSG_MOVE = 1 << 0, MSG_COPY = 1 << 1, - + MSG_QUEUED = 1 << 16, MSG_DRAFT = 1 << 17, MSG_ENCRYPTED = 1 << 18, @@ -86,10 +87,11 @@ typedef enum MSG_FILTERING = 1 << 25, /* claws: re/set by filtering */ MSG_MIME = 1 << 29, + MSG_CACHED = 1 << 31 } MsgTmpFlags; -#define MSG_CACHED_FLAG_MASK (MSG_MIME) +#define MSG_CACHED_FLAG_MASK (MSG_MIME) #define MSG_SET_FLAGS(msg, flags) { (msg) |= (flags); } #define MSG_UNSET_FLAGS(msg, flags) { (msg) &= ~(flags); } @@ -109,6 +111,11 @@ typedef enum #define MSG_IS_REPLIED(msg) (((msg).perm_flags & MSG_REPLIED) != 0) #define MSG_IS_FORWARDED(msg) (((msg).perm_flags & MSG_FORWARDED) != 0) +#define MSG_GET_COLORLABEL(msg) (((msg).perm_flags & MSG_CLABEL_FLAG_MASK)) +#define MSG_GET_COLORLABEL_VALUE(msg) (MSG_GET_COLORLABEL(msg) >> MSG_CLABEL_SBIT) +#define MSG_SET_COLORLABEL_VALUE(msg, val) \ + MSG_SET_PERM_FLAGS(msg, ((((guint)(val)) & 7) << MSG_CLABEL_SBIT)) + #define MSG_IS_MOVE(msg) (((msg).tmp_flags & MSG_MOVE) != 0) #define MSG_IS_COPY(msg) (((msg).tmp_flags & MSG_COPY) != 0) @@ -123,10 +130,6 @@ typedef enum /* Claws related flags */ #define MSG_IS_REALLY_DELETED(msg) (((msg).perm_flags & MSG_REALLY_DELETED) != 0) #define MSG_IS_IGNORE_THREAD(msg) (((msg).perm_flags & MSG_IGNORE_THREAD) != 0) -#define MSG_GET_LABEL(msg) (((msg).perm_flags & MSG_LABEL)) -#define MSG_GET_LABEL_VALUE(msg) (MSG_GET_LABEL(msg) >> MSG_LABEL_SBIT) -/* 7 == nr. of colors excl. none */ -#define MSG_SET_LABEL_VALUE(msg, val) MSG_SET_PERM_FLAGS(msg, ((((unsigned)(val)) & 7) << MSG_LABEL_SBIT)) #define MSG_IS_FILTERING(msg) (((msg).tmp_flags & MSG_FILTERING) != 0) diff --git a/src/send.c b/src/send.c index 1fec8be84..040f670d2 100644 --- a/src/send.c +++ b/src/send.c @@ -36,7 +36,9 @@ #include "intl.h" #include "send.h" #include "socket.h" +#include "ssl.h" #include "smtp.h" +#include "esmtp.h" #include "prefs_account.h" #include "account.h" #include "compose.h" @@ -61,24 +63,23 @@ struct _SendProgressDialog gboolean cancelled; }; -#if !USE_SSL +#if USE_SSL static gint send_message_smtp (GSList *to_list, const gchar *from, const gchar *server, gushort port, const gchar *domain, const gchar *userid, const gchar *passwd, gboolean use_smtp_auth, - FILE *fp); - + SSLSMTPType ssl_type, FILE *fp); static SockInfo *send_smtp_open (const gchar *server, gushort port, - const gchar *domain, gboolean use_smtp_auth); + const gchar *domain, gboolean use_smtp_auth, + SSLSMTPType ssl_type); #else static gint send_message_smtp (GSList *to_list, const gchar *from, const gchar *server, gushort port, const gchar *domain, const gchar *userid, const gchar *passwd, gboolean use_smtp_auth, - FILE *fp, SSLSMTPType ssl); - + FILE *fp); static SockInfo *send_smtp_open (const gchar *server, gushort port, - const gchar *domain, gboolean use_smtp_auth, SSLSMTPType ssl); + const gchar *domain, gboolean use_smtp_auth); #endif static SendProgressDialog *send_progress_dialog_create(void); @@ -109,25 +110,25 @@ gint send_message(const gchar *file, PrefsAccount *ac_prefs, GSList *to_list) ac_prefs->mail_command, fp); } else { -#if !USE_SSL - port = ac_prefs->set_smtpport ? ac_prefs->smtpport : SMTP_PORT; +#if USE_SSL + port = ac_prefs->set_smtpport ? ac_prefs->smtpport : + ac_prefs->ssl_smtp == SSL_SMTP_TUNNEL ? SSMTP_PORT : SMTP_PORT; #else - port = ac_prefs->set_smtpport ? ac_prefs->smtpport : - (ac_prefs->ssl_smtp == SSL_SMTP_TUNNEL ? SSMTP_PORT : SMTP_PORT); + port = ac_prefs->set_smtpport ? ac_prefs->smtpport : SMTP_PORT; #endif - domain = ac_prefs->set_domain ? ac_prefs->domain : NULL; + domain = ac_prefs->set_domain ? ac_prefs->domain : NULL; -#if !USE_SSL - val = send_message_smtp(to_list, ac_prefs->address, - ac_prefs->smtp_server, port, domain, - ac_prefs->userid, ac_prefs->passwd, - ac_prefs->use_smtp_auth, fp); +#if USE_SSL + val = send_message_smtp(to_list, ac_prefs->address, + ac_prefs->smtp_server, port, domain, + ac_prefs->userid, ac_prefs->passwd, + ac_prefs->use_smtp_auth, ac_prefs->ssl_smtp, + fp); #else - val = send_message_smtp(to_list, ac_prefs->address, - ac_prefs->smtp_server, port, domain, - ac_prefs->userid, ac_prefs->passwd, - ac_prefs->use_smtp_auth, fp, - ac_prefs->ssl_smtp); + val = send_message_smtp(to_list, ac_prefs->address, + ac_prefs->smtp_server, port, domain, + ac_prefs->userid, ac_prefs->passwd, + ac_prefs->use_smtp_auth, fp); #endif } @@ -239,31 +240,34 @@ gint send_message_queue(const gchar *file) } if (ac) { -#if !USE_SSL - port = ac->set_smtpport ? ac->smtpport : SMTP_PORT; +#if USE_SSL + port = ac->set_smtpport ? ac->smtpport : + ac->ssl_smtp == SSL_SMTP_TUNNEL ? + SSMTP_PORT : SMTP_PORT; #else - port = ac->set_smtpport ? ac->smtpport : (ac->ssl_smtp == SSL_SMTP_TUNNEL ? SSMTP_PORT : SMTP_PORT); + port = ac->set_smtpport ? ac->smtpport : SMTP_PORT; #endif domain = ac->set_domain ? ac->domain : NULL; -#if !USE_SSL +#if USE_SSL val = send_message_smtp (to_list, from, server, port, domain, - ac->userid, ac->passwd, ac->use_smtp_auth, fp); + ac->userid, ac->passwd, ac->use_smtp_auth, + ac->ssl_smtp, fp); #else val = send_message_smtp (to_list, from, server, port, domain, - ac->userid, ac->passwd, ac->use_smtp_auth, fp, ac->ssl_smtp); + ac->userid, ac->passwd, ac->use_smtp_auth, fp); #endif } else { g_warning(_("Account not found.\n")); -#if !USE_SSL +#if USE_SSL val = send_message_smtp (to_list, from, server, SMTP_PORT, NULL, - NULL, NULL, FALSE, fp); + NULL, NULL, FALSE, FALSE, fp); #else val = send_message_smtp (to_list, from, server, SMTP_PORT, NULL, - NULL, NULL, FALSE, fp, FALSE); + NULL, NULL, FALSE, fp); #endif } } @@ -310,18 +314,18 @@ gint send_message_queue(const gchar *file) } \ } -#if !USE_SSL +#if USE_SSL static gint send_message_smtp(GSList *to_list, const gchar *from, const gchar *server, gushort port, const gchar *domain, const gchar *userid, const gchar *passwd, gboolean use_smtp_auth, - FILE *fp) + SSLSMTPType ssl_type, FILE *fp) #else static gint send_message_smtp(GSList *to_list, const gchar *from, const gchar *server, gushort port, const gchar *domain, const gchar *userid, const gchar *passwd, gboolean use_smtp_auth, - FILE *fp, SSLSMTPType ssl) + FILE *fp) #endif { SockInfo *smtp_sock = NULL; @@ -358,13 +362,13 @@ static gint send_message_smtp(GSList *to_list, const gchar *from, gtk_clist_set_text(clist, 0, 2, _("Connecting")); GTK_EVENTS_FLUSH(); -#if !USE_SSL +#if USE_SSL SEND_EXIT_IF_ERROR((smtp_sock = send_smtp_open - (server, port, domain, use_smtp_auth)), + (server, port, domain, use_smtp_auth, ssl_type)), "connecting to server"); #else SEND_EXIT_IF_ERROR((smtp_sock = send_smtp_open - (server, port, domain, use_smtp_auth, ssl)), + (server, port, domain, use_smtp_auth)), "connecting to server"); #endif @@ -422,22 +426,19 @@ static gint send_message_smtp(GSList *to_list, const gchar *from, SEND_EXIT_IF_NOTOK(smtp_eom(smtp_sock), "terminating data"); SEND_EXIT_IF_NOTOK(smtp_quit(smtp_sock), "sending QUIT"); -#if USE_SSL - ssl_done_socket(smtp_sock); -#endif - sock_close(smtp_sock); send_progress_dialog_destroy(dialog); return 0; } -#if !USE_SSL +#if USE_SSL static SockInfo *send_smtp_open(const gchar *server, gushort port, - const gchar *domain, gboolean use_smtp_auth) + const gchar *domain, gboolean use_smtp_auth, + SSLSMTPType ssl_type) #else static SockInfo *send_smtp_open(const gchar *server, gushort port, - const gchar *domain, gboolean use_smtp_auth, SSLSMTPType ssl) + const gchar *domain, gboolean use_smtp_auth) #endif { SockInfo *sock; @@ -452,32 +453,52 @@ static SockInfo *send_smtp_open(const gchar *server, gushort port, } #if USE_SSL - if((ssl == SSL_SMTP_TUNNEL) && !ssl_init_socket(sock)) { + if (ssl_type == SSL_SMTP_TUNNEL && !ssl_init_socket(sock)) { log_warning(_("SSL connection failed")); sock_close(sock); return NULL; } #endif - if (smtp_ok(sock) == SM_OK) { - val = smtp_helo(sock, domain ? domain : get_domain_name(), - use_smtp_auth); - if (val != SM_OK) { - log_warning(_("Error occurred while sending HELO\n")); - sock_close(sock); - return NULL; - } + if (smtp_ok(sock) != SM_OK) { + log_warning(_("Error occurred while connecting to %s:%d\n"), + server, port); + sock_close(sock); + return NULL; } #if USE_SSL - if(ssl == SSL_SMTP_STARTTLS) { - val = smtp_starttls(sock, domain ? domain : get_domain_name(), - use_smtp_auth); + val = smtp_helo(sock, domain ? domain : get_domain_name(), + use_smtp_auth || ssl_type == SSL_SMTP_STARTTLS); +#else + val = smtp_helo(sock, domain ? domain : get_domain_name(), + use_smtp_auth); +#endif + + if (val != SM_OK) { + log_warning(_("Error occurred while sending HELO\n")); + sock_close(sock); + return NULL; + } + +#if USE_SSL + if (ssl_type == SSL_SMTP_STARTTLS) { + val = esmtp_starttls(sock); if (val != SM_OK) { log_warning(_("Error occurred while sending STARTTLS\n")); sock_close(sock); return NULL; } + if (!ssl_init_socket_with_method(sock, SSL_METHOD_TLSv1)) { + sock_close(sock); + return NULL; + } + val = esmtp_ehlo(sock, domain ? domain : get_domain_name()); + if (val != SM_OK) { + log_warning(_("Error occurred while sending EHLO\n")); + sock_close(sock); + return NULL; + } } #endif diff --git a/src/smtp.c b/src/smtp.c index e36fb0e91..fa6d9fab1 100644 --- a/src/smtp.c +++ b/src/smtp.c @@ -31,15 +31,11 @@ static gint verbose = 1; static gchar smtp_response[MSGBUFSIZE]; -gint smtp_helo(SockInfo *sock, const char *hostname, gboolean use_smtp_auth) +gint smtp_helo(SockInfo *sock, const gchar *hostname, gboolean esmtp) { - if (use_smtp_auth) { - sock_printf(sock, "EHLO %s\r\n", hostname); - if (verbose) - log_print("ESMTP> EHLO %s\n", hostname); - - return esmtp_ok(sock); - } else { + if (esmtp) + return esmtp_ehlo(sock, hostname); + else { sock_printf(sock, "HELO %s\r\n", hostname); if (verbose) log_print("SMTP> HELO %s\n", hostname); @@ -66,7 +62,7 @@ gint smtp_from(SockInfo *sock, const gchar *from, } else authtype = SMTPAUTH_CRAM_MD5; - esmtp_auth(sock, authtype, userid, passwd, use_smtp_auth); + esmtp_auth(sock, authtype, userid, passwd); } if (strchr(from, '<')) @@ -160,24 +156,3 @@ gint smtp_ok(SockInfo *sock) return SM_UNRECOVERABLE; } - -#if USE_SSL -gint smtp_starttls(SockInfo *sock, const char *hostname, gboolean use_smtp_auth) -{ - gint ret; - - sock_printf(sock, "STARTTLS\r\n", hostname); - if (verbose) - log_print("SMTP> STARTTLS\n", hostname); - - ret = smtp_ok(sock); - if(ret != SM_OK) - return ret; - - if(!ssl_init_socket_with_method(sock, SSL_METHOD_TLSv1)) { - return SM_ERROR; - } - - return smtp_helo(sock, hostname, use_smtp_auth); -} -#endif \ No newline at end of file diff --git a/src/smtp.h b/src/smtp.h index 42ae2295e..cd989cade 100644 --- a/src/smtp.h +++ b/src/smtp.h @@ -34,7 +34,7 @@ #define ESMTP_SIZE 0x02 #define ESMTP_ETRN 0x04 -gint smtp_helo(SockInfo *sock, const char *hostname, gboolean use_smtp_auth); +gint smtp_helo(SockInfo *sock, const gchar *hostname, gboolean esmtp); gint smtp_from(SockInfo *sock, const gchar *from, const gchar *userid, const gchar *passwd, gboolean use_smtp_auth); gint smtp_rcpt(SockInfo *sock, const gchar *to); diff --git a/src/socket.c b/src/socket.c index 0468b2ce0..acd7192b8 100644 --- a/src/socket.c +++ b/src/socket.c @@ -41,6 +41,9 @@ #endif #include "socket.h" +#if USE_SSL +# include "ssl.h" +#endif #if USE_GIO #error USE_GIO is currently not supported @@ -258,48 +261,6 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port) } #endif /* !INET6 */ -#if 0 -SockInfo *sock_connect_nb(const gchar *hostname, gushort port) -{ - gint sock; - gint ret; - SockInfo *sockinfo; - -#ifdef INET6 - if ((sock = sock_connect_by_getaddrinfo(hostname, port)) < 0) - return NULL; - if (set_nonblocking_mode(sock, TRUE) < 0) return NULL; - ret = sock; -#else - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - perror("socket"); - return NULL; - } - - if (set_nonblocking_mode(sock, TRUE) < 0) return NULL; - - ret = sock_connect_by_hostname(sock, hostname, port); - - if (ret < 0 && errno != EINPROGRESS) { - if (errno != 0) perror("connect"); - close(sock); - return NULL; - } -#endif /* INET6 */ - - sockinfo = g_new0(SockInfo, 1); - sockinfo->sock = sock; - sockinfo->hostname = g_strdup(hostname); - sockinfo->port = port; - sockinfo->state = CONN_LOOKUPSUCCESS; - - if (ret < 0 && errno == EINPROGRESS) return sockinfo; - - sockinfo->state = CONN_ESTABLISHED; - return sockinfo; -} -#endif - SockInfo *sock_connect(const gchar *hostname, gushort port) { gint sock; @@ -398,9 +359,8 @@ gint sock_read(SockInfo *sock, gchar *buf, gint len) g_return_val_if_fail(sock != NULL, -1); #if USE_SSL - if(sock->ssl) { + if (sock->ssl) return ssl_read(sock->ssl, buf, len); - } #endif return fd_read(sock->sock, buf, len); } @@ -410,7 +370,7 @@ gint fd_read(gint fd, gchar *buf, gint len) return read(fd, buf, len); } -#ifdef USE_SSL +#if USE_SSL gint ssl_read(SSL *ssl, gchar *buf, gint len) { return SSL_read(ssl, buf, len); @@ -422,9 +382,8 @@ gint sock_write(SockInfo *sock, const gchar *buf, gint len) g_return_val_if_fail(sock != NULL, -1); #if USE_SSL - if(sock->ssl) { + if (sock->ssl) return ssl_write(sock->ssl, buf, len); - } #endif return fd_write(sock->sock, buf, len); } @@ -445,7 +404,7 @@ gint fd_write(gint fd, const gchar *buf, gint len) return wrlen; } -#ifdef USE_SSL +#if USE_SSL gint ssl_write(SSL *ssl, const gchar *buf, gint len) { gint n, wrlen = 0; @@ -488,24 +447,23 @@ gint fd_gets(gint fd, gchar *buf, gint len) #if USE_SSL gint ssl_gets(SSL *ssl, gchar *buf, gint len) { - gchar *buf2 = buf; + gchar *bp = buf; gboolean newline = FALSE; - gint n, count = 0; + gint n; if (--len < 1) return -1; - while(len > 0 && !newline) { - *buf2 = '\0'; - if((n = SSL_read(ssl, buf2, 1)) < 0) + while (len > 0 && !newline) { + *bp = '\0'; + if ((n = SSL_read(ssl, bp, 1)) < 0) return -1; - if(*buf2 == '\n') + if (*bp == '\n') newline = TRUE; - buf2 += n; - count += n; + bp += n; } - *buf2 = '\0'; - return count; + *bp = '\0'; + return bp - buf; } #endif @@ -514,9 +472,8 @@ gint sock_gets(SockInfo *sock, gchar *buf, gint len) g_return_val_if_fail(sock != NULL, -1); #if USE_SSL - if(sock->ssl) { + if (sock->ssl) return ssl_gets(sock->ssl, buf, len); - } #endif return fd_gets(sock->sock, buf, len); } @@ -572,9 +529,8 @@ gchar *sock_getline(SockInfo *sock) g_return_val_if_fail(sock != NULL, NULL); #if USE_SSL - if(sock->ssl) { + if (sock->ssl) return ssl_getline(sock->ssl); - } #endif return fd_getline(sock->sock); } @@ -609,6 +565,10 @@ gint sock_close(SockInfo *sock) if (!sock) return 0; +#if USE_SSL + if (sock->ssl) + ssl_done_socket(sock); +#endif ret = fd_close(sock->sock); g_free(sock->hostname); g_free(sock); diff --git a/src/socket.h b/src/socket.h index ac06ef74b..b5a3d456a 100644 --- a/src/socket.h +++ b/src/socket.h @@ -94,7 +94,6 @@ gint sock_gdk_input_add (SockInfo *sock, GdkInputFunction function, gpointer data); - /* Functions to directly work on FD. They are needed for pipes */ gint fd_connect_unix (const gchar *path); gint fd_open_unix (const gchar *path); @@ -106,4 +105,12 @@ gint fd_gets (gint sock, gchar *buf, gint len); gchar *fd_getline (gint sock); gint fd_close (gint sock); +/* Functions for SSL */ +#if USE_SSL +gint ssl_read(SSL *ssl, gchar *buf, gint len); +gint ssl_write(SSL *ssl, const gchar *buf, gint len); +gint ssl_gets(SSL *ssl, gchar *buf, gint len); +gchar *ssl_getline(SSL *ssl); +#endif + #endif /* __SOCKET_H__ */ diff --git a/src/ssl.c b/src/ssl.c index 308890ed3..075f7b6be 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -23,63 +23,69 @@ #if USE_SSL +#include "defs.h" + +#include + #include "intl.h" #include "utils.h" #include "ssl.h" -SSL_CTX *ssl_ctx_SSLv23; -SSL_CTX *ssl_ctx_TLSv1; +static SSL_CTX *ssl_ctx_SSLv23; +static SSL_CTX *ssl_ctx_TLSv1; -void ssl_init() { - SSL_METHOD *meth; - +void ssl_init(void) +{ SSL_library_init(); SSL_load_error_strings(); - + ssl_ctx_SSLv23 = SSL_CTX_new(SSLv23_client_method()); - if(ssl_ctx_SSLv23 == NULL) { - debug_print(_("SSLv23 not available\n")); + if (ssl_ctx_SSLv23 == NULL) { + debug_print(_("SSLv23 not available\n")); } else { debug_print(_("SSLv23 available\n")); } ssl_ctx_TLSv1 = SSL_CTX_new(TLSv1_client_method()); - if(ssl_ctx_TLSv1 == NULL) { - debug_print(_("TLSv1 not available\n")); + if (ssl_ctx_TLSv1 == NULL) { + debug_print(_("TLSv1 not available\n")); } else { debug_print(_("TLSv1 available\n")); } } -void ssl_done() { - if(ssl_ctx_SSLv23) { - SSL_CTX_free(ssl_ctx_SSLv23); +void ssl_done(void) +{ + if (ssl_ctx_SSLv23) { + SSL_CTX_free(ssl_ctx_SSLv23); } - if(ssl_ctx_TLSv1) { - SSL_CTX_free(ssl_ctx_TLSv1); + if (ssl_ctx_TLSv1) { + SSL_CTX_free(ssl_ctx_TLSv1); } } -gboolean ssl_init_socket(SockInfo *sockinfo) { +gboolean ssl_init_socket(SockInfo *sockinfo) +{ return ssl_init_socket_with_method(sockinfo, SSL_METHOD_SSLv23); } -gboolean ssl_init_socket_with_method(SockInfo *sockinfo, SSL_METHODs method) { +gboolean ssl_init_socket_with_method(SockInfo *sockinfo, SSLMethod method) +{ X509 *server_cert; - int ret; + gint ret; - switch(method) { + switch (method) { case SSL_METHOD_SSLv23: - if(!ssl_ctx_SSLv23) { - log_warning(_("SSL method not available\n")); + if (!ssl_ctx_SSLv23) { + log_warning(_("SSL method not available\n")); return FALSE; } sockinfo->ssl = SSL_new(ssl_ctx_SSLv23); break; case SSL_METHOD_TLSv1: - if(!ssl_ctx_TLSv1) { - log_warning(_("SSL method not available\n")); + if (!ssl_ctx_TLSv1) { + log_warning(_("SSL method not available\n")); return FALSE; } sockinfo->ssl = SSL_new(ssl_ctx_TLSv1); @@ -89,17 +95,16 @@ gboolean ssl_init_socket_with_method(SockInfo *sockinfo, SSL_METHODs method) { return FALSE; break; } - - if(sockinfo->ssl == NULL) { - log_warning(_("Error creating ssl context\n")); + if (sockinfo->ssl == NULL) { + log_warning(_("Error creating ssl context\n")); return FALSE; } SSL_set_fd(sockinfo->ssl, sockinfo->sock); - if((ret = SSL_connect(sockinfo->ssl)) == -1) { - log_warning(_("SSL connect failed (%s)\n"), ERR_error_string(ERR_get_error(), NULL)); - + if ((ret = SSL_connect(sockinfo->ssl)) == -1) { + log_warning(_("SSL connect failed (%s)\n"), + ERR_error_string(ERR_get_error(), NULL)); return FALSE; } @@ -109,31 +114,32 @@ gboolean ssl_init_socket_with_method(SockInfo *sockinfo, SSL_METHODs method) { /* Get server's certificate (note: beware of dynamic allocation) */ - if((server_cert = SSL_get_peer_certificate(sockinfo->ssl)) != NULL) { - char *str; - + if ((server_cert = SSL_get_peer_certificate(sockinfo->ssl)) != NULL) { + gchar *str; + log_print(_("Server certificate:\n")); - if((str = X509_NAME_oneline(X509_get_subject_name (server_cert),0,0)) != NULL) { + if ((str = X509_NAME_oneline(X509_get_subject_name(server_cert), 0, 0)) != NULL) { log_print(_(" Subject: %s\n"), str); free(str); } - - if((str = X509_NAME_oneline(X509_get_issuer_name (server_cert),0,0)) != NULL) { + + if ((str = X509_NAME_oneline(X509_get_issuer_name(server_cert), 0, 0)) != NULL) { log_print(_(" Issuer: %s\n"), str); free(str); } X509_free(server_cert); } - + return TRUE; } -void ssl_done_socket(SockInfo *sockinfo) { - if(sockinfo->ssl) { +void ssl_done_socket(SockInfo *sockinfo) +{ + if (sockinfo->ssl) { SSL_free(sockinfo->ssl); } } -#endif /* USE_SSL */ \ No newline at end of file +#endif /* USE_SSL */ diff --git a/src/ssl.h b/src/ssl.h index 5f2468f10..52ee7045e 100644 --- a/src/ssl.h +++ b/src/ssl.h @@ -17,11 +17,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#if USE_SSL - #ifndef __SSL_H__ #define __SSL_H__ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if USE_SSL + +#include #include #include #include @@ -33,14 +38,14 @@ typedef enum { SSL_METHOD_SSLv23, SSL_METHOD_TLSv1 -} SSL_METHODs; +} SSLMethod; -void ssl_init(); -void ssl_done(); +void ssl_init(void); +void ssl_done(void); gboolean ssl_init_socket(SockInfo *sockinfo); -gboolean ssl_init_socket_with_method(SockInfo *sockinfo, SSL_METHODs method); +gboolean ssl_init_socket_with_method(SockInfo *sockinfo, SSLMethod method); void ssl_done_socket(SockInfo *sockinfo); -#endif /* __SSL_H__ */ - #endif /* USE_SSL */ + +#endif /* __SSL_H__ */ diff --git a/src/summaryview.c b/src/summaryview.c index e33a276b6..bb924c59e 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -71,12 +71,12 @@ #include "statusbar.h" #include "filter.h" #include "folder.h" +#include "colorlabel.h" #include "addressbook.h" #include "addr_compl.h" #include "scoring.h" #include "prefs_folder_item.h" #include "filtering.h" -#include "labelcolors.h" #include "pixmaps/dir-open.xpm" #include "pixmaps/mark.xpm" @@ -237,6 +237,14 @@ static void summary_filter_func (GtkCTree *ctree, GtkCTreeNode *node, gpointer data); +static void summary_colorlabel_menu_item_activate_cb + (GtkWidget *widget, + gpointer data); +static void summary_colorlabel_menu_item_activate_item_cb + (GtkMenuItem *label_menu_item, + gpointer data); +static void summary_colorlabel_menu_create(SummaryView *summaryview); + /* callback functions */ static void summary_toggle_pressed (GtkWidget *eventbox, GdkEventButton *event, @@ -373,185 +381,6 @@ static GtkItemFactoryEntry summary_popup_entries[] = {N_("/Select _all"), NULL, summary_select_all, 0, NULL} }; -#define LABEL_COLORS_ELEMS labelcolors_get_color_count() - -static void label_menu_item_activate_cb(GtkWidget *widget, gpointer data) -{ - guint color = GPOINTER_TO_UINT(data); - SummaryView *view = gtk_object_get_data(GTK_OBJECT(widget), "view"); - - g_return_if_fail(view); - - /* "dont_toggle" state set? */ - if (gtk_object_get_data(GTK_OBJECT(view->label_menu), "dont_toggle")) - return; - - summary_set_label(view, color, NULL); -} - -/* summary_set_label_color() - labelcolor parameter is the color *flag* - * for the messsage; not the color index */ -void summary_set_label_color(GtkCTree *ctree, GtkCTreeNode *node, - guint labelcolor) -{ - GdkColor color; - GtkStyle *style, *prev_style, *ctree_style; - MsgInfo *msginfo; - gint color_index; - - color_index = labelcolor == 0 ? -1 : (gint) labelcolor - 1; - - ctree_style = gtk_widget_get_style(GTK_WIDGET(ctree)); - - prev_style = gtk_ctree_node_get_row_style(ctree, node); - - if (!prev_style) - prev_style = ctree_style; - - style = gtk_style_copy(prev_style); - - if (color_index < 0 || color_index >= LABEL_COLORS_ELEMS) { - color_index = 0; - color.red = ctree_style->fg[GTK_STATE_NORMAL].red; - color.green = ctree_style->fg[GTK_STATE_NORMAL].green; - color.blue = ctree_style->fg[GTK_STATE_NORMAL].blue; - style->fg[GTK_STATE_NORMAL] = color; - - color.red = ctree_style->fg[GTK_STATE_SELECTED].red; - color.green = ctree_style->fg[GTK_STATE_SELECTED].green; - color.blue = ctree_style->fg[GTK_STATE_SELECTED].blue; - style->fg[GTK_STATE_SELECTED] = color; - gtk_ctree_node_set_row_style(ctree, node, style); - } - else { - color = labelcolors_get_color(color_index); - } - - msginfo = gtk_ctree_node_get_row_data(ctree, node); - - MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_LABEL); - MSG_SET_LABEL_VALUE(msginfo->flags, labelcolor); - - if ( style ) { - style->fg[GTK_STATE_NORMAL] = color; - style->fg[GTK_STATE_SELECTED] = color; - gtk_ctree_node_set_row_style(ctree, node, style); - } -} - -void summary_set_label(SummaryView *summaryview, guint labelcolor, GtkWidget *widget) -{ - GtkCTree *ctree = GTK_CTREE(summaryview->ctree); - GtkCList *clist = GTK_CLIST(summaryview->ctree); - GList *cur; - - for (cur = clist->selection; cur != NULL; cur = cur->next) - summary_set_label_color(ctree, GTK_CTREE_NODE(cur->data), labelcolor); -} - -static void label_menu_item_activate_item_cb(GtkMenuItem *label_menu_item, gpointer data) -{ - SummaryView *summaryview; - GtkMenuShell *label_menu; - GtkCheckMenuItem **items; - int n; - GList *cur, *sel; - - summaryview = (SummaryView *) data; - g_return_if_fail(summaryview); - if (NULL == (sel = GTK_CLIST(summaryview->ctree)->selection)) - return; - - label_menu = GTK_MENU_SHELL(summaryview->label_menu); - g_return_if_fail(label_menu); - - items = alloca( (LABEL_COLORS_ELEMS + 1) * sizeof(GtkWidget *)); - g_return_if_fail(items); - - /* NOTE: don't return prematurely because we set the "dont_toggle" state - * for check menu items */ - gtk_object_set_data(GTK_OBJECT(label_menu), "dont_toggle", GINT_TO_POINTER(1)); - - /* clear items. get item pointers. */ - for (n = 0, cur = label_menu->children; cur != NULL; cur = cur->next) { - if (GTK_IS_CHECK_MENU_ITEM(cur->data)) { - gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(cur->data), FALSE); - items[n] = GTK_CHECK_MENU_ITEM(cur->data); - n++; - } - } - - if (n == (LABEL_COLORS_ELEMS + 1)) { - /* iterate all messages and set the state of the appropriate items */ - for (; sel != NULL; sel = sel->next) { - MsgInfo *msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree), - GTK_CTREE_NODE(sel->data)); - gint menu_item; - if (msginfo) { - menu_item = MSG_GET_LABEL_VALUE(msginfo->flags); - if (!items[menu_item]->active) - gtk_check_menu_item_set_state(items[menu_item], TRUE); - } - } - } - else - g_warning("invalid number of color elements (%d)\n", n); - - /* reset "dont_toggle" state */ - gtk_object_set_data(GTK_OBJECT(label_menu), "dont_toggle", GINT_TO_POINTER(0)); -} - -static void summary_create_label_menu(SummaryView *summaryview) -{ - const gint LABEL_MENU_POS = 5; - GtkWidget *label_menu_item; - GtkWidget *label_menu; - GtkWidget *item; - gint i; - - label_menu_item = gtk_menu_item_new_with_label(_("Label")); - gtk_menu_insert(GTK_MENU(summaryview->popupmenu), label_menu_item, LABEL_MENU_POS); - gtk_signal_connect(GTK_OBJECT(label_menu_item), "activate", - GTK_SIGNAL_FUNC(label_menu_item_activate_item_cb), summaryview); - - gtk_widget_show(label_menu_item); - summaryview->label_menu_item = label_menu_item; - - label_menu = gtk_menu_new(); - - /* create sub items. for the menu item activation callback we pass the - * index of label_colors[] as data parameter. for the None color we pass - * an invalid (high) value. also we attach a data pointer so we can - * always get back the SummaryView pointer. */ - - item = gtk_check_menu_item_new_with_label(_("None")); - gtk_menu_append(GTK_MENU(label_menu), item); - gtk_signal_connect(GTK_OBJECT(item), "activate", - GTK_SIGNAL_FUNC(label_menu_item_activate_cb), - GUINT_TO_POINTER(0)); - gtk_object_set_data(GTK_OBJECT(item), "view", summaryview); - gtk_widget_show(item); - - item = gtk_menu_item_new(); - gtk_menu_append(GTK_MENU(label_menu), item); - gtk_widget_show(item); - - /* create pixmap/label menu items */ - for (i = 0; i < LABEL_COLORS_ELEMS; i++) { - item = labelcolors_create_check_color_menu_item(i); - gtk_menu_append(GTK_MENU(label_menu), item); - gtk_signal_connect(GTK_OBJECT(item), "activate", - GTK_SIGNAL_FUNC(label_menu_item_activate_cb), - GUINT_TO_POINTER(i + 1)); - gtk_object_set_data(GTK_OBJECT(item), "view", summaryview); - gtk_widget_show(item); - } - - gtk_widget_show(label_menu); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menu_item), label_menu); - summaryview->label_menu = label_menu; -} - SummaryView *summary_create(void) { SummaryView *summaryview; @@ -834,8 +663,8 @@ void summary_init(SummaryView *summaryview) gtk_widget_show(pixmap); summary_clear_list(summaryview); + summary_colorlabel_menu_create(summaryview); summary_set_menu_sensitive(summaryview); - summary_create_label_menu(summaryview); } @@ -1208,7 +1037,7 @@ static void summary_set_menu_sensitive(SummaryView *summaryview) menu_set_sensitive(ifactory, "/Copy...", TRUE); } - gtk_widget_set_sensitive(summaryview->label_menu_item, TRUE); + gtk_widget_set_sensitive(summaryview->colorlabel_menu_item, TRUE); menu_set_sensitive(ifactory, "/Execute", TRUE); sens = (selection == SUMMARY_SELECTED_MULTIPLE) ? FALSE : TRUE; @@ -1922,8 +1751,8 @@ static void summary_set_ctree_from_list(SummaryView *summaryview, GTKUT_CTREE_NODE_SET_ROW_DATA(node, msginfo); summary_set_marks_func(ctree, node, summaryview); - if (MSG_GET_LABEL(msginfo->flags)) - summary_set_label_color(ctree, node, MSG_GET_LABEL_VALUE(msginfo->flags)); + if (MSG_GET_COLORLABEL(msginfo->flags)) + summary_set_colorlabel_color(ctree, node, MSG_GET_COLORLABEL_VALUE(msginfo->flags)); /* preserve previous node if the message is duplicated */ @@ -1987,8 +1816,8 @@ static void summary_set_ctree_from_list(SummaryView *summaryview, GTKUT_CTREE_NODE_SET_ROW_DATA(node, msginfo); summary_set_marks_func(ctree, node, summaryview); - if ( MSG_GET_LABEL(msginfo->flags) ) - summary_set_label_color(ctree, node, MSG_GET_LABEL_VALUE(msginfo->flags)); + if ( MSG_GET_COLORLABEL(msginfo->flags) ) + summary_set_colorlabel_color(ctree, node, MSG_GET_COLORLABEL_VALUE(msginfo->flags)); if (msginfo->msgid && *msginfo->msgid && g_hash_table_lookup(msgid_table, msginfo->msgid) @@ -2520,6 +2349,10 @@ static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row) style = small_style; gtk_ctree_node_set_row_style(ctree, row, style); + + if (MSG_GET_COLORLABEL(flags)) + summary_set_colorlabel_color(ctree, row, + MSG_GET_COLORLABEL_VALUE(flags)); } void summary_set_marks_selected(SummaryView *summaryview) @@ -3500,6 +3333,197 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node, summaryview->folder_table); } +/* color label */ + +#define LABEL_COLORS_ELEMS colorlabel_get_color_count() + +static void summary_colorlabel_menu_item_activate_cb(GtkWidget *widget, + gpointer data) +{ + guint color = GPOINTER_TO_UINT(data); + SummaryView *summaryview; + + summaryview = gtk_object_get_data(GTK_OBJECT(widget), "summaryview"); + g_return_if_fail(summaryview != NULL); + + /* "dont_toggle" state set? */ + if (gtk_object_get_data(GTK_OBJECT(summaryview->colorlabel_menu), + "dont_toggle")) + return; + + summary_set_colorlabel(summaryview, color, NULL); +} + +/* summary_set_colorlabel_color() - labelcolor parameter is the color *flag* + * for the messsage; not the color index */ +void summary_set_colorlabel_color(GtkCTree *ctree, GtkCTreeNode *node, + guint labelcolor) +{ + GdkColor color; + GtkStyle *style, *prev_style, *ctree_style; + MsgInfo *msginfo; + gint color_index; + + color_index = labelcolor == 0 ? -1 : (gint)labelcolor - 1; + ctree_style = gtk_widget_get_style(GTK_WIDGET(ctree)); + prev_style = gtk_ctree_node_get_row_style(ctree, node); + if (!prev_style) + prev_style = ctree_style; + style = gtk_style_copy(prev_style); + + if (color_index < 0 || color_index >= LABEL_COLORS_ELEMS) { + color_index = 0; + color.red = ctree_style->fg[GTK_STATE_NORMAL].red; + color.green = ctree_style->fg[GTK_STATE_NORMAL].green; + color.blue = ctree_style->fg[GTK_STATE_NORMAL].blue; + style->fg[GTK_STATE_NORMAL] = color; + + color.red = ctree_style->fg[GTK_STATE_SELECTED].red; + color.green = ctree_style->fg[GTK_STATE_SELECTED].green; + color.blue = ctree_style->fg[GTK_STATE_SELECTED].blue; + style->fg[GTK_STATE_SELECTED] = color; + gtk_ctree_node_set_row_style(ctree, node, style); + } else + color = colorlabel_get_color(color_index); + + msginfo = gtk_ctree_node_get_row_data(ctree, node); + + MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_CLABEL_FLAG_MASK); + MSG_SET_COLORLABEL_VALUE(msginfo->flags, labelcolor); + + if (style) { + style->fg[GTK_STATE_NORMAL] = color; + style->fg[GTK_STATE_SELECTED] = color; + gtk_ctree_node_set_row_style(ctree, node, style); + } +} + +void summary_set_colorlabel(SummaryView *summaryview, guint labelcolor, + GtkWidget *widget) +{ + GtkCTree *ctree = GTK_CTREE(summaryview->ctree); + GtkCList *clist = GTK_CLIST(summaryview->ctree); + GList *cur; + + for (cur = clist->selection; cur != NULL; cur = cur->next) + summary_set_colorlabel_color(ctree, GTK_CTREE_NODE(cur->data), + labelcolor); +} + +static void summary_colorlabel_menu_item_activate_item_cb(GtkMenuItem *label_menu_item, + gpointer data) +{ + SummaryView *summaryview; + GtkMenuShell *label_menu; + GtkCheckMenuItem **items; + gint n; + GList *cur, *sel; + + summaryview = (SummaryView *)data; + g_return_if_fail(summaryview != NULL); + + sel = GTK_CLIST(summaryview->ctree)->selection; + if (!sel) return; + + label_menu = GTK_MENU_SHELL(summaryview->colorlabel_menu); + g_return_if_fail(label_menu != NULL); + + Xalloca(items, (LABEL_COLORS_ELEMS + 1) * sizeof(GtkWidget *), return); + + /* NOTE: don't return prematurely because we set the "dont_toggle" + * state for check menu items */ + gtk_object_set_data(GTK_OBJECT(label_menu), "dont_toggle", + GINT_TO_POINTER(1)); + + /* clear items. get item pointers. */ + for (n = 0, cur = label_menu->children; cur != NULL; cur = cur->next) { + if (GTK_IS_CHECK_MENU_ITEM(cur->data)) { + gtk_check_menu_item_set_state + (GTK_CHECK_MENU_ITEM(cur->data), FALSE); + items[n] = GTK_CHECK_MENU_ITEM(cur->data); + n++; + } + } + + if (n == (LABEL_COLORS_ELEMS + 1)) { + /* iterate all messages and set the state of the appropriate + * items */ + for (; sel != NULL; sel = sel->next) { + MsgInfo *msginfo; + gint menu_item; + + msginfo = gtk_ctree_node_get_row_data + (GTK_CTREE(summaryview->ctree), + GTK_CTREE_NODE(sel->data)); + if (msginfo) { + menu_item = MSG_GET_COLORLABEL_VALUE(msginfo->flags); + if (!items[menu_item]->active) + gtk_check_menu_item_set_state + (items[menu_item], TRUE); + } + } + } else + g_warning("invalid number of color elements (%d)\n", n); + + /* reset "dont_toggle" state */ + gtk_object_set_data(GTK_OBJECT(label_menu), "dont_toggle", + GINT_TO_POINTER(0)); +} + +static void summary_colorlabel_menu_create(SummaryView *summaryview) +{ + const gint LABEL_MENU_POS = 5; + GtkWidget *label_menu_item; + GtkWidget *label_menu; + GtkWidget *item; + gint i; + + label_menu_item = gtk_menu_item_new_with_label(_("Color label")); + gtk_menu_insert(GTK_MENU(summaryview->popupmenu), label_menu_item, + LABEL_MENU_POS); + gtk_signal_connect(GTK_OBJECT(label_menu_item), "activate", + GTK_SIGNAL_FUNC(summary_colorlabel_menu_item_activate_item_cb), + summaryview); + + gtk_widget_show(label_menu_item); + summaryview->colorlabel_menu_item = label_menu_item; + + label_menu = gtk_menu_new(); + + /* create sub items. for the menu item activation callback we pass the + * index of label_colors[] as data parameter. for the None color we + * pass an invalid (high) value. also we attach a data pointer so we + * can always get back the SummaryView pointer. */ + + item = gtk_check_menu_item_new_with_label(_("None")); + gtk_menu_append(GTK_MENU(label_menu), item); + gtk_signal_connect(GTK_OBJECT(item), "activate", + GTK_SIGNAL_FUNC(summary_colorlabel_menu_item_activate_cb), + GUINT_TO_POINTER(0)); + gtk_object_set_data(GTK_OBJECT(item), "summaryview", summaryview); + gtk_widget_show(item); + + item = gtk_menu_item_new(); + gtk_menu_append(GTK_MENU(label_menu), item); + gtk_widget_show(item); + + /* create pixmap/label menu items */ + for (i = 0; i < LABEL_COLORS_ELEMS; i++) { + item = colorlabel_create_check_color_menu_item(i); + gtk_menu_append(GTK_MENU(label_menu), item); + gtk_signal_connect(GTK_OBJECT(item), "activate", + GTK_SIGNAL_FUNC(summary_colorlabel_menu_item_activate_cb), + GUINT_TO_POINTER(i + 1)); + gtk_object_set_data(GTK_OBJECT(item), "summaryview", + summaryview); + gtk_widget_show(item); + } + + gtk_widget_show(label_menu); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menu_item), label_menu); + summaryview->colorlabel_menu = label_menu; +} + /* callback functions */ static void summary_toggle_pressed(GtkWidget *eventbox, GdkEventButton *event, @@ -4099,7 +4123,7 @@ static gint summary_cmp_by_label(GtkCList *clist, MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data; MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data; - return MSG_GET_LABEL(msginfo1->flags) - MSG_GET_LABEL(msginfo2->flags); + return MSG_GET_COLORLABEL(msginfo1->flags) - MSG_GET_COLORLABEL(msginfo2->flags); } static gint summary_cmp_by_score(GtkCList *clist, diff --git a/src/summaryview.h b/src/summaryview.h index 489198158..794843cbe 100644 --- a/src/summaryview.h +++ b/src/summaryview.h @@ -92,8 +92,8 @@ struct _SummaryView GtkWidget *toggle_eventbox; GtkWidget *toggle_arrow; GtkWidget *popupmenu; - GtkWidget *label_menu_item; /* label menu item */ - GtkWidget *label_menu; /* label menu itself */ + GtkWidget *colorlabel_menu; + GtkWidget *colorlabel_menu_item; GtkItemFactory *popupfactory; @@ -204,7 +204,12 @@ void summary_mark_as_unread (SummaryView *summaryview); void summary_mark_as_read (SummaryView *summaryview); void summary_select_all (SummaryView *summaryview); void summary_unselect_all (SummaryView *summaryview); -void summary_set_label (SummaryView *summaryview, guint labelcolor, GtkWidget *widget); -void summary_set_label_color (GtkCTree *ctree, GtkCTreeNode *node, guint labelcolor); + +void summary_set_colorlabel (SummaryView *summaryview, + guint labelcolor, + GtkWidget *widget); +void summary_set_colorlabel_color (GtkCTree *ctree, + GtkCTreeNode *node, + guint labelcolor); #endif /* __SUMMARY_H__ */