sync with sylpheed 0.4.65cvs10

This commit is contained in:
Alfons Hoogervorst 2001-04-27 20:27:24 +00:00
parent 700e6b3b53
commit 6d56b06e24
56 changed files with 2214 additions and 821 deletions

187
ChangeLog
View file

@ -1,3 +1,190 @@
2001-04-26
* src/mh.c: mh_is_maildir_one(): modified so that it uses
is_dir_exist().
2001-04-25 Werner Koch <wk@gnupg.org>
* src/mh.c (mh_is_maildir_one, mh_is_maildir): New.
(mh_scan_tree_recursive): Do not include Maildir style directories
in the scan.
Changed the use of integers to describe sockets by an more abstract
data structure.
* src/automaton.h (struct _Automaton): Add help_sock.
* src/automaton.c (automaton_input_cb): Changed source to be
SockInfo and use wrapper for gdk_input_add.
* src/send.c (SEND_EXIT_IF_ERROR): Adjusted tests and removed test
for invalid socket because this is now done in sock_close. Set
sock to NULL.
(SEND_EXIT_IF_NOTOK): Set closed sock to NULL.
(send_smtp_open): Use only SockInfo.
* src/news.c (news_session_new): Use SockInfo here.
(news_session_destroy): Ditto and set sock to NULL.
* src/nntp.c: Use SockInfo instead of integers
* src/smtp.c: Ditto.
* src/pop.c: Ditto.
* src/recv.c: Ditto.
* src/inc.c (inc_pop3_session_do): Removed sock_sockinfo_free. Put
gdk_input_add into a wrapper.
* src/esmtp.c: Changed socket descriptors to use SockInfo.
* src/esmtp.h: Ditto, included socket.h.
* src/session.h (struct _Session): Likewise.
* src/imap.c (imap_open): Return SockInfo ptr and not an integer.
Removed access to internal data of SockInfo. Changed all callers
and functions to take SockInfo.
(imap_session_new): Use sock_close here.
(imap_session_destroy): Ditto.
* src/compose.c (compose_exec_ext_editor): Replaced sock_write by
fd_write.
* src/main.c (app_will_exit): Close lock socket using fd_close.
(prohibit_duplicate_launch): Use fd_xxx functions instead of sock_xxx.
(lock_socket_input_cb): Ditto.
* src/socket.h, src/socket.c: Prepared SockInfo structure to use
glib channels. Changed all sock_xxx to use SockInfo instead of an
integer.
(sock_connect_unix, sock_open_unix, sock_accept): Renamed to ..
(fd_connect_unix, fd_open_unix, fd_accept): .. this and changed all
callers.
(fd_read, fd_write, fd_close): New.
(sock_sockinfo_free): Removed.
* src/socket.c (sock_connect_nb): Use close instead sock_close here.
(sock_connect): Ditto.
2001-04-26
* config.h.in: removed.
* ac/Makefile.am: added gnupg-check-typedef.m4 to MACROS.
* .cvsignore: added.
* src/inc.c
src/progressdialog.[ch]
src/pixmaps/complete.xpm
src/pixmaps/continue.xpm
src/pixmaps/error.xpm: applied the patch from Leandro Pereira
that displays the state of message incorporation (thanks!).
* src/inc.c: made the progress dialog change the text of status.
2001-04-25
* removed po/*.gmo, configure, stamp-h.in, aclocal.m4, Makefile.in
from the cvs tree.
* COPYING: removed RSA copyright notice.
* removed po/sylpheed.pot, po/stamp-cat-id, po/cat-id-tbl.c.
* configure.in: added the check of sys/utsname.h.
2001-04-24 Werner Koch <wk@gnupg.org>
Merged most of the changes from the W32 branch in.
* configure.in: Require gpgme >= 0.2.1
* acconfig.h (HAVE_U32_TYPEDEF): New.
* ac/gnupg-check-typedef.m4: New.
* configure.in: Check for u32 type and the size of some types.
* src/utils.h: Define the u32 type and related constants.
* src/about.c (about_create): Removed the note about MD5. We are
not any longer using the RSA Inc. implementation.
* src/md5ify.c, src/md5ify.h, src/md5global.h: Removed.
* src/md5c.c, src/md5c.h: Replaced by an FSF implementation and
renamed the function to standard lowercase convention. Changed all
callers.
(md5_hex_digest): New.
(md5_hmac): Add hmac function by Martin Schaaf with some
modifications.
(md5_hex_hmac): New.
* src/esmtp.c, src/esmtp.h (md5_hex_hmac): Removed.
(hmac_md5): Removed.
* src/pop.c (pop3_getauth_apop_send): Replaced the md5_digest by
the new md5_hex_digest function.
* src/about.c: Include utsname.h only if available
* src/utils.c, src/utils.h (get_home_dir): New to better cope with
special Windoze requirements. Changed all calls to
g_get_home_dir() to this function.
* simple-gettext.c: New.
* src/main.c (main): Issue a warning if GnuPG is not properly
installed.
* src/sigstatus.c, src/sigstatus.h: New.
* src/rfc2015.c (check_signature): Use the sigstatus window and
get the status texts from a utility function.
* src/select-keys.c: Removed the global select_keys var and
pass an allocated one along all functions.
(set_row): Display only keys capable of encryption.
(update_progress): Replaced the progressbar by
a windmill and a text showing for which key we are collecting
info. Removed progressbar everywhere else and updated callers.
* src/prefs_common.c (prefs_privacy_create) [__MINGW32__]: Do not
display the grab button.
2001-04-24
* src/prefs_common.[ch]
src/procheader.c: applied the patch from Darko Koruga that
allows user to define their own format for displaying date in
summary view using strftime() (thanks!).
* src/prefs_common.c: prefs_quote_colors_dialog()
src/mainwindow.c: main_window_reflect_prefs_all(): made it
update message colors if the colors setting is changed.
* src/main.[ch]: made it remember the startup directory.
* src/export.c: export_mbox(): made it initially chdir to the
startup directory.
* src/filesel.c: filesel_select_file(): made it open the startup
directory at first.
2001-04-23
* added option to warn about queued messages on exit [sergey]:
* src/compose.c: compose_queue(): call folder_item_scan()
and folderview_update_item() after queueing.
* src/folderview.c: folderview_update_node(): draw the queue
folder in bold font if there are queued messages.
* src/mainwindow.c: queued_messages(): new function.
app_exit_cb(): display warning if there are queued messages
if warn_queued_on_exit is set.
* prefs_common.[ch]: add warn_queued_on_exit option.
* src/mainwindow.c: moved queued_messages() to main.c, and renamed
it to get_queued_message_num().
* src/main.c: app_will_exit(): moved warning dialog code from
app_exit_cb(), and added manage_window_focus_in().
* enhanced GnuPG key selection support [sergey]:
* src/select-keys.c: updated to newer version from Win32
branch with support for selecting arbitrary keys.
* src/prefs_account.c: added the Privacy tab to the account
options window.
prefs_account_privacy_create(),
prefs_account_sign_key_set_data_from_radiobtn(),
prefs_account_sign_key_set_radiobtn(): new functions.
* src/prefs_account.h: new preferences sign_key_type, sign_key_id.
* src/rfc2015.c: set_signers(): new function.
pgp_sign(): add the account parameter, call set_signers().
rfc2015_sign(): add the account parameter, pass it to pgp_sign().
* src/rfc2015.h: rfc2015_sign(): updated prototype.
* src/compose.c: pass the current account to rfc2015_sign().
2001-04-22
* src/mbox.c: export_to_mbox(): fixed a memory leak bug.
2001-04-20
* src/mbox.[ch]: renamed export_mbox() to export_to_mbox().

View file

@ -1,3 +1,8 @@
2001-04-27 [alfons]
* completed sync with 0.4.65cvs10
* minor debug things added to gtkstext.c
2001-04-27 [darko]
* configure.in: remove check for availability of

View file

@ -1,3 +1,194 @@
2001-04-26
* src/mh.c: mh_is_maildir_one(): is_dir_exist() を使用するように
修正。
2001-04-25 Werner Koch <wk@gnupg.org>
* src/mh.c (mh_is_maildir_one, mh_is_maildir): 新規。
(mh_scan_tree_recursive): スキャンで Maildir 型のディレクトリを
含まないようにした。
整数型で socket を表していたのを、より抽象的なデータ構造に変更。
* src/automaton.h (struct _Automaton): help_sock を追加。
* src/automaton.c (automaton_input_cb): source を SockInfo に追加
し、 gdk_input_add のラッパーを使用するようにした。
* src/send.c (SEND_EXIT_IF_ERROR): テストを修正し、無効な socket
のテストを取り除いた(sock_close で行われるため)。 sock を NULL
にセットするようにした。
(SEND_EXIT_IF_NOTOK): 閉じられた sock を NULL にセットするように
した。
(send_smtp_open): SockInfo のみを使用するようにした。
* src/news.c (news_session_new): SockInfo を使用。
(news_session_destroy): 同上、 sock を NULL にセット。
* src/nntp.c: 整数型の代わりに SockInfo を使用。
* src/smtp.c: 同上。
* src/pop.c: 同上。
* src/recv.c: 同上。
* src/inc.c (inc_pop3_session_do): sock_sockinfo_free を削除。
gdk_input_add をラッパーで包んだ。
* src/esmtp.c: socket 指示子を SockInfo を使うように変更。
* src/esmtp.h: 同上、 socket.h を include した。
* src/session.h (struct _Session): 同じく。
* src/imap.c (imap_open): 整数型でなく SockInfo を返すようにした。
SockInfo の内部データへのアクセスを削除。全ての呼び出し側と関数
が SockInfo をとるようにした。
(imap_session_new): sock_close を使用するようにした。
(imap_session_destroy): 同上。
* src/compose.c (compose_exec_ext_editor): sock_write を fd_write
で置き換えた。
* src/main.c (app_will_exit): lock socket を fd_close で close する
ようにした。
(prohibit_duplicate_launch): sock_xxx の代わりに fd_xxx を使用。
(lock_socket_input_cb): 同上。
* src/socket.h, src/socket.c: SockInfo 構造体を glib チャネルを
使用するように準備。全ての sock_xxx を、整数型の代わりに SockInfo
を使用するように変更。
(sock_connect_unix, sock_open_unix, sock_accept): 名前を ..
(fd_connect_unix, fd_open_unix, fd_accept): .. これに変更し、全ての
呼び出し側も変更。
(fd_read, fd_write, fd_close): 新規。
(sock_sockinfo_free): 削除。
* src/socket.c (sock_connect_nb): ここでは sock_close の代わりに
close を使用。
(sock_connect): 同上。
2001-04-26
* config.h.in: 削除。
* ac/Makefile.am: gnupg-check-typedef.m4 を MACROS に追加。
* .cvsignore: 追加。
* src/inc.c
src/progressdialog.[ch]
src/pixmaps/complete.xpm
src/pixmaps/continue.xpm
src/pixmaps/error.xpm: メッセージの取り込みの状態を表示する
Leandro Pereira さんのパッチを適用(thanks!)。
* src/inc.c: 状態の文字列を切替えるようにした。
2001-04-25
* cvs ツリーから po/*.gmo, configure, stamp-h.in, aclocal.m4,
Makefile.in を削除。
* COPYING: RSA の著作権表示を削除。
* po/sylpheed.pot, po/stamp-cat-id, po/cat-id-tbl.c を削除。
* configure.in: sys/utsname.h のチェックを追加。
2001-04-24 Werner Koch <wk@gnupg.org>
W32 ブランチの大部分をマージ。
* configure.in: gpgme >= 0.2.1 を要求。
* acconfig.h (HAVE_U32_TYPEDEF): 新規。
* ac/gnupg-check-typedef.m4: 新規。
* configure.in: u32 型といくつかの型のサイズをチェック。
* src/utils.h: u32 型と関係する定数を定義。
* src/about.c (about_create): MD5 に関する表示を削除。RSA Inc の
実装はもう使用されていません。
* src/md5ify.c, src/md5ify.h, src/md5global.h: 削除。
* src/md5c.c, src/md5c.h: FSF の実装で置換し、関数名を標準の小文字
の命名規則にしたがって変更。全ての呼び出し側を変更。
(md5_hex_digest): 新規。
(md5_hmac): Martin Schaaf さんによる hmac 関数を少し修正して追加。
(md5_hex_hmac): 新規。
* src/esmtp.c, src/esmtp.h (md5_hex_hmac): 削除。
(hmac_md5): 削除。
* src/pop.c (pop3_getauth_apop_send): md5_digest を新しい関数
md5_hex_digest で置換。
* src/about.c: 利用可能な場合のみ utsname.h を include するように
した。
* src/utils.c, src/utils.h (get_home_dir): 特別な Windoze の要求
によりよく対応するために追加。全ての g_get_home_dir() の呼び出し
をこの関数に変更。
* simple-gettext.c: 新規。
* src/main.c (main): GnuPG が正しくインストールされていなければ
警告を出すようにした。
* src/sigstatus.c, src/sigstatus.h: 新規。
* src/rfc2015.c (check_signature): sigstatus ウィンドウを使用し、
ユーティリティ関数からステータステキストを得るようにした。
* src/select-keys.c: グローバルの select_keys 変数を削除し、
アロケートした変数を全ての関数で渡すようにした。
(set_row): 暗号化できる鍵のみを表示。
(update_progress): プログレスバーを、風車とどの鍵の情報を収集
しているかを示すテキストで置き換えた。他の全てのプログレスバー
を削除し、呼び出し側を更新。
* src/prefs_common.c (prefs_privacy_create) [__MINGW32__]: 捕捉
ボタンを表示しないようにした。
2001-04-24
* src/prefs_common.[ch]
src/procheader.c: strftime() を使い、ユーザがサマリビューで
日付の表示の書式を定義できるようにする Darko Koruga さんのパッチ
を適用(thanks!)。
* src/prefs_common.c: prefs_quote_colors_dialog()
src/mainwindow.c: main_window_reflect_prefs_all(): 色の設定が
変更されたらメッセージの色を更新するようにした。
* src/main.[ch]: 起動時のディレクトリを記憶するようにした。
* src/export.c: export_mbox(): 最初に起動時のディレクトリに chdir
するようにした。
* src/filesel.c: filesel_select_file(): 最初に起動時のディレクトリ
を開くようにした。
2001-04-23
* 終了時に送信待ちのメッセージがあれば警告するオプションを追加
[sergey]:
* src/compose.c: compose_queue(): 送信待機後に folder_item_scan()
と folderview_update_item() を呼ぶようにした。
* src/folderview.c: folderview_update_node(): 送信待ちのメッセージ
があれば送信待ちフォルダをボールドフォントで描画するようにした。
* src/mainwindow.c: queued_messages(): 新しい関数。
app_exit_cb(): warn_queued_on_exit がセットされていて、送信待ち
のメッセージがあれば警告を表示するようにした。
* prefs_common.[ch]: warn_queued_on_exit オプションを追加。
* src/mainwindow.c: queued_messages() を main.c に移動し、
get_queued_message_num() に名称変更。
* src/main.c: app_will_exit(): app_exit_cb() から警告ダイアログの
コードを移動し、manage_window_focus_in() を追加。
* GnuPG 鍵選択対応を拡張 [sergey]:
* src/select-keys.c: Win32 ブランチの最新版に更新し、任意の鍵の
選択に対応。
* src/prefs_account.c: アカウントオプションウィンドウに「機密」
タブを追加。
prefs_account_privacy_create(),
prefs_account_sign_key_set_data_from_radiobtn(),
prefs_account_sign_key_set_radiobtn(): 新しい関数。
* src/prefs_account.h: 新しい設定: sign_key_type, sign_key_id.
* src/rfc2015.c: set_signers(): 新しい関数。
pgp_sign(): アカウントパラメータと set_signer() の呼出しを追加。
rfc2015_sign(): アカウントパラメータを追加し、pgp_sign() に
渡すようにした。
* src/rfc2015.h: rfc2015_sign(): プロトタイプを更新。
* src/compose.c: 現在のアカウントを rfc2015_sign() に渡すように
した。
2001-04-22
* src/mbox.c: export_to_mbox(): メモリリークのバグを修正。
2001-04-20
* src/mbox.[ch]: export_mbox() を export_to_mbox() に変更。

View file

@ -21,5 +21,8 @@
/* Define to `unsigned int' if <stddef.h> or <wchar.h> doesn't define. */
#undef wint_t
/* Used to test for a u32 typedef */
#undef HAVE_U32_TYPEDEF
#undef PACKAGE
#undef VERSION

View file

@ -8,7 +8,7 @@ MINOR_VERSION=4
MICRO_VERSION=65
INTERFACE_AGE=65
BINARY_AGE=65
EXTRA_VERSION=claws5
EXTRA_VERSION=claws6
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl

View file

@ -45,8 +45,7 @@ sylpheed_SOURCES = \
unmime.c unmime.h \
base64.c base64.h \
uuencode.c uuencode.h \
md5c.c md5.h md5global.h \
md5ify.c md5ify.h \
md5c.c md5.h \
rfc822.c rfc822.h \
socket.c socket.h \
automaton.c automaton.h \
@ -60,6 +59,7 @@ sylpheed_SOURCES = \
recv.c recv.h \
inc.c inc.h \
import.c import.h \
export.c export.h \
nntp.c nntp.h \
news.c news.h \
imap.c imap.h \
@ -69,9 +69,10 @@ sylpheed_SOURCES = \
rfc2015.c rfc2015.h \
passphrase.c passphrase.h \
select-keys.c select-keys.h \
sigstatus.c sigstatus.h \
simple-gettext.c \
manual.c manual.h \
addr_compl.c addr_compl.h \
export.c export.h \
gtkstext.c gtkstext.h \
grouplist_dialog.c grouplist_dialog.h \
headers.c headers.h \

View file

@ -36,7 +36,9 @@
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtktext.h>
#include <gtk/gtkbutton.h>
#include <sys/utsname.h>
#if HAVE_SYS_UTSNAME_H
# include <sys/utsname.h>
#endif
#include "intl.h"
#include "about.h"
@ -77,8 +79,10 @@ static void about_create(void)
GdkColormap *cmap;
GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
gboolean success[2];
#if HAVE_SYS_UTSNAME_H
struct utsname utsbuf;
#endif
gchar buf[1024];
gint i;
@ -87,7 +91,7 @@ static void about_create(void)
gtk_container_set_border_width(GTK_CONTAINER(window), 8);
gtk_widget_set_usize(window, 518, 358);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
//gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
/* gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); */
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), NULL);
gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
@ -103,13 +107,20 @@ static void about_create(void)
label = gtk_label_new("version "VERSION);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
#if HAVE_SYS_UTSNAME_H
uname(&utsbuf);
g_snprintf(buf, sizeof(buf),
"GTK+ version %d.%d.%d\n"
"Operating System: %s %s (%s)",
gtk_major_version, gtk_minor_version, gtk_micro_version,
utsbuf.sysname, utsbuf.release, utsbuf.machine);
#else
g_snprintf(buf, sizeof(buf),
"GTK+ version %d.%d.%d\n"
"Operating System: Windoze",
gtk_major_version, gtk_minor_version, gtk_micro_version);
#endif
label = gtk_label_new(buf);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
@ -191,10 +202,6 @@ static void about_create(void)
"1993 and 1995. Copyright retained for the purpose of protecting free "
"redistribution of source.\n\n"), -1);
gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
_("The MD5 support is copyright by RSA Data Security, Inc. See the "
"header comment of the md5.c module for license terms.\n\n"), -1);
gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
_("Kcc is copyright by Yasuhiro Tonooka <tonooka@msi.co.jp>, "
"and libkcc is copyright by takeshi@SoftAgency.co.jp.\n\n"), -1);

View file

@ -44,14 +44,22 @@ void automaton_destroy(Automaton *atm)
g_free(atm);
}
void automaton_input_cb(gpointer data, gint source,
GdkInputCondition condition)
void automaton_input_cb(gpointer data, gint dummy_source,
GdkInputCondition condition)
{
Automaton *atm = (Automaton *)data;
SockInfo *sock;
gint next;
/* We get out sockinfo from the atm context and not from the
* passed file descriptor because we can't map that one back
* to the sockinfo */
sock = atm->help_sock;
g_assert (sock->sock == dummy_source);
//g_print("atm->num = %d\n", atm->num);
if (atm->timeout_tag > 0) {
gtk_timeout_remove(atm->timeout_tag);
atm->timeout_tag = 0;
@ -59,19 +67,20 @@ void automaton_input_cb(gpointer data, gint source,
}
gdk_input_remove(atm->tag);
atm->tag = 0;
next = atm->state[atm->num].handler(source, atm->data);
next = atm->state[atm->num].handler(sock, atm->data);
if (atm->terminated)
return;
if (next >= 0 && next <= atm->max && next != atm->num) {
atm->num = next;
atm->tag = gdk_input_add(source,
atm->state[atm->num].condition,
atm->tag = sock_gdk_input_add(sock,
atm->state[atm->num].condition,
automaton_input_cb,
data);
data);
} else {
atm->terminate(source, data);
atm->terminate(sock, data);
}
}

View file

@ -22,15 +22,17 @@
#include <glib.h>
#include "socket.h"
typedef struct _AtmState AtmState;
typedef struct _Automaton Automaton;
typedef gint (*AtmHandler) (gint source, gpointer data);
typedef gint (*AtmHandler) (SockInfo *source, gpointer data);
struct _AtmState
{
GdkInputCondition condition;
gint (*handler)(gint source, gpointer data);
gint (*handler)(SockInfo *source, gpointer data);
};
struct _Automaton
@ -43,12 +45,13 @@ struct _Automaton
gboolean terminated;
gpointer data;
AtmState *state;
gint (*terminate)(gint source, gpointer data);
gint (*terminate)(SockInfo *source, gpointer data);
SockInfo *help_sock;
};
Automaton *automaton_create(gint num);
void automaton_destroy(Automaton *atm);
void automaton_input_cb(gpointer data, gint source,
void automaton_input_cb(gpointer data, gint dummy_source,
GdkInputCondition condition);
#endif /* __AUTOMATON_H__ */

View file

@ -1171,7 +1171,7 @@ static void compose_insert_sig(Compose *compose)
if (compose->account && compose->account->sig_path)
sigfile = g_strdup(compose->account->sig_path);
else {
sigfile = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S,
sigfile = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
DEFAULT_SIGNATURE, NULL);
}
@ -3235,20 +3235,20 @@ static void compose_exec_ext_editor(Compose *compose)
close(pipe_fds[0]);
if (compose_write_body_to_file(compose, tmp) < 0) {
sock_write(pipe_fds[1], "2\n", 2);
fd_write(pipe_fds[1], "2\n", 2);
_exit(1);
}
pid_ed = compose_exec_ext_editor_real(tmp);
if (pid_ed < 0) {
sock_write(pipe_fds[1], "1\n", 2);
fd_write(pipe_fds[1], "1\n", 2);
_exit(1);
}
/* wait until editor is terminated */
waitpid(pid_ed, NULL, 0);
sock_write(pipe_fds[1], "0\n", 2);
fd_write(pipe_fds[1], "0\n", 2);
close(pipe_fds[1]);
_exit(0);

View file

@ -33,90 +33,7 @@
static gint verbose = 1;
static gchar esmtp_response[MSGBUFSIZE];
/*
** Function: hmac_md5
** taken from the file rfc2104.txt
*/
void hmac_md5(guchar *text, gint text_len, guchar *key, gint key_len,
guchar *digest)
{
MD5_CTX context;
guchar k_ipad[65]; /* inner padding -
* key XORd with ipad
*/
guchar k_opad[65]; /* outer padding -
* key XORd with opad
*/
guchar tk[16];
gint i;
/* if key is longer than 64 bytes reset it to key=MD5(key) */
if (key_len > 64) {
MD5_CTX tctx;
MD5Init(&tctx);
MD5Update(&tctx, key, key_len);
MD5Final(tk, &tctx);
key = tk;
key_len = 16;
}
/*
* the HMAC_MD5 transform looks like:
*
* MD5(K XOR opad, MD5(K XOR ipad, text))
*
* where K is an n byte key
* ipad is the byte 0x36 repeated 64 times
* opad is the byte 0x5c repeated 64 times
* and text is the data being protected
*/
/* start out by storing key in pads */
bzero(k_ipad, sizeof k_ipad);
bzero(k_opad, sizeof k_opad);
bcopy(key, k_ipad, key_len);
bcopy(key, k_opad, key_len);
/* XOR key with ipad and opad values */
for (i = 0; i < 64; i++) {
k_ipad[i] ^= 0x36;
k_opad[i] ^= 0x5c;
}
/*
* perform inner MD5
*/
MD5Init(&context); /* init context for 1st
* pass */
MD5Update(&context, k_ipad, 64); /* start with inner pad */
MD5Update(&context, text, text_len); /* then text of datagram */
MD5Final(digest, &context); /* finish up 1st pass */
/*
* perform outer MD5
*/
MD5Init(&context); /* init context for 2nd
* pass */
MD5Update(&context, k_opad, 64); /* start with outer pad */
MD5Update(&context, digest, 16); /* then results of 1st
* hash */
MD5Final(digest, &context); /* finish up 2nd pass */
}
void md5_hex_hmac(gchar *hexdigest, guchar *text, gint text_len,
guchar *key, gint key_len)
{
guchar digest[16];
gint i;
hmac_md5(text, text_len, key, key_len, digest);
for(i = 0; i < 16; i++)
sprintf(hexdigest + 2 * i, "%02x", digest[i]);
}
gint esmtp_auth_cram_md5(gint sock)
gint esmtp_auth_cram_md5(SockInfo *sock)
{
gchar buf[MSGBUFSIZE];
@ -129,7 +46,7 @@ gint esmtp_auth_cram_md5(gint sock)
return esmtp_ok(sock);
}
gint esmtp_auth_login(gint sock)
gint esmtp_auth_login(SockInfo *sock)
{
gchar buf[MSGBUFSIZE];
@ -142,7 +59,7 @@ gint esmtp_auth_login(gint sock)
return esmtp_ok(sock);
}
gint esmtp_auth(gint sock, SMTPAuthType authtype,
gint esmtp_auth(SockInfo *sock, SMTPAuthType authtype,
const gchar *userid, const gchar *passwd,
gboolean use_smtp_auth)
{
@ -221,7 +138,7 @@ gint esmtp_auth(gint sock, SMTPAuthType authtype,
return esmtp_ok(sock);
}
gint esmtp_ok(gint sock)
gint esmtp_ok(SockInfo *sock)
{
while (sock_read(sock, esmtp_response, sizeof(esmtp_response) - 1)
!= -1) {

View file

@ -21,6 +21,7 @@
#define __ESMTP_H__
#include <glib.h>
#include "socket.h"
typedef enum
{
@ -29,13 +30,11 @@ typedef enum
SMTPAUTH_DIGEST_MD5 = 3
} SMTPAuthType;
gint esmtp_auth_login(gint sock);
gint esmtp_auth_cram_md5(gint sock);
gint esmtp_auth(gint sock, SMTPAuthType authtype,
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);
gint esmtp_ok(gint sock);
void md5_hex_hmac(gchar *hexdigest, guchar *text, gint text_len,
guchar *key, gint key_len);
gint esmtp_ok(SockInfo *sock);
#endif /* __ESMTP_H__ */

View file

@ -46,6 +46,7 @@
#include "gtkutils.h"
#include "manage_window.h"
#include "folder.h"
#include "utils.h"
static GtkWidget *window;
static GtkWidget *src_entry;
@ -72,6 +73,8 @@ gint export_mbox(FolderItem *default_src)
else
gtk_widget_show(window);
change_dir(startup_dir);
if (default_src && default_src->path)
gtk_entry_set_text(GTK_ENTRY(src_entry), default_src->path);
else

View file

@ -24,6 +24,7 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include "main.h"
#include "filesel.h"
#include "manage_window.h"
#include "gtkutils.h"
@ -51,7 +52,7 @@ gchar *filesel_select_file(const gchar *title, const gchar *file)
}
if (!cwd)
cwd = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, NULL);
cwd = g_strconcat(startup_dir, G_DIR_SEPARATOR_S, NULL);
gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), cwd);

View file

@ -442,11 +442,11 @@ gchar *folder_item_get_path(FolderItem *item)
path = g_strdup(folder_path);
} else {
if (item->path)
path = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S,
path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
folder_path, G_DIR_SEPARATOR_S,
item->path, NULL);
else
path = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S,
path = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
folder_path, NULL);
}

View file

@ -477,6 +477,13 @@ static void gtk_stext_show_props (GtkSText* test,
#define TEXT_SHOW_ADJ(text,adj,msg)
#endif
#define AHX_DEBUG
#if defined(AHX_DEBUG)
# define XDEBUG(args) g_message args
#else
# define XDEBUG(args)
#endif /* AHX_DEBUG */
/* Memory Management. */
static GMemChunk *params_mem_chunk = NULL;
static GMemChunk *text_property_chunk = NULL;
@ -2264,15 +2271,19 @@ gtk_stext_key_press (GtkWidget *widget,
}
break;
case GDK_Delete:
if (event->state & GDK_CONTROL_MASK)
gtk_stext_delete_forward_word (text);
else if (event->state & GDK_SHIFT_MASK)
{
extend_selection = FALSE;
gtk_editable_cut_clipboard (editable);
}
else
gtk_stext_delete_forward_character (text);
{
if (event->state & GDK_CONTROL_MASK) {
gtk_stext_delete_forward_word (text);
}
else if (event->state & GDK_SHIFT_MASK)
{
extend_selection = FALSE;
gtk_editable_cut_clipboard (editable);
}
else {
gtk_stext_delete_forward_character (text);
}
}
break;
case GDK_Tab:
position = text->point.index;
@ -4215,14 +4226,14 @@ static gint back_display_row_fetcher(GtkSText *text,
{
if (data->start <= params->start.index
&& data->end >= params->end.index) {
TDEBUG( ("%s(%d) - FOUND search (%d, %d), current (%d, %d)", __FILE__, __LINE__,
XDEBUG( ("%s(%d) - FOUND search (%d, %d), current (%d, %d)", __FILE__, __LINE__,
data->start, data->end,
params->start.index, params->end.index) )
params->start.index, params->end.index) );
data->found = TRUE;
return TRUE;
}
else {
TDEBUG( ("%s(%d) - NEXT search (%d, %d), current (%d, %d)", __FILE__, __LINE__,
XDEBUG( ("%s(%d) - NEXT search (%d, %d), current (%d, %d)", __FILE__, __LINE__,
data->start, data->end,
params->start.index, params->end.index) );
data->lp = *params;
@ -4240,7 +4251,7 @@ static void move_cursor_to_display_row_up(GtkSText *text)
/* top of buffer */
if (mark.index == 0) {
TDEBUG ( ("%s(%d) top of buffer", __FILE__, __LINE__) );
XDEBUG ( ("%s(%d) top of buffer", __FILE__, __LINE__) );
return;
}
@ -4255,30 +4266,30 @@ static void move_cursor_to_display_row_up(GtkSText *text)
/* get the previous line */
if (mark.index - 1 > 0) {
decrement_mark(&mark);
TDEBUG( ("%s(%d) mark decrement", __FILE__, __LINE__) );
XDEBUG( ("%s(%d) mark decrement", __FILE__, __LINE__) );
if (mark.index - 1 > 0) {
GtkSPropertyMark smark = mark;
TDEBUG( ("%s(%d) finding line start mark", __FILE__, __LINE__) );
XDEBUG( ("%s(%d) finding line start mark", __FILE__, __LINE__) );
mark = find_this_line_start_mark(text, smark.index -1, &smark);
}
}
/* let's get the previous display line */
TDEBUG( ("%s(%d) iterating to get display lines", __FILE__, __LINE__) );
XDEBUG( ("%s(%d) iterating to get display lines", __FILE__, __LINE__) );
line_params_iterate(text, &mark, NULL, FALSE, &data,
(LineIteratorFunction)back_display_row_fetcher);
TDEBUG( ("%s(%d) done iterating. found = %d", __FILE__, __LINE__, data.found) );
XDEBUG( ("%s(%d) done iterating. found = %d", __FILE__, __LINE__, data.found) );
if (data.found) {
if (col < text->persist_column) col = text->persist_column;
else text->persist_column = col;
new_index = data.lp.start.index + col;
TDEBUG( ("%s(%d) - new index = %d", __FILE__, __LINE__, new_index) );
XDEBUG( ("%s(%d) - new index = %d", __FILE__, __LINE__, new_index) );
if (new_index > data.lp.end.index) {
new_index = data.lp.end.index;
}
/* and move the cursor */
TDEBUG( ("%s(%d) - setting index", __FILE__, __LINE__) );
XDEBUG( ("%s(%d) - setting index", __FILE__, __LINE__) );
gtk_stext_set_position_X(GTK_EDITABLE(text), new_index);
}
}
@ -4577,8 +4588,9 @@ static void
gtk_stext_kill_word (GtkEditable *editable,
gint direction)
{
if (editable->selection_start_pos != editable->selection_end_pos)
if (editable->selection_start_pos != editable->selection_end_pos) {
gtk_editable_delete_selection (editable);
}
else
{
gint old_pos = editable->current_pos;

View file

@ -53,34 +53,34 @@ static GSList *imap_delete_messages (GSList *mlist,
gint last);
static void imap_delete_all_messages (FolderItem *item);
static gint imap_open (const gchar *server,
static SockInfo *imap_open (const gchar *server,
gushort port,
gchar *buf);
static gint imap_auth (gint sock,
static gint imap_auth (SockInfo *sock,
const gchar *user,
const gchar *pass);
static gint imap_logout (gint sock);
static gint imap_noop (gint sock);
static gint imap_select (gint sock,
static gint imap_logout (SockInfo *sock);
static gint imap_noop (SockInfo *sock);
static gint imap_select (SockInfo *sock,
const gchar *folder,
gint *exists,
gint *recent,
gint *unseen,
gulong *uid);
static gint imap_get_envelope (gint sock,
static gint imap_get_envelope (SockInfo *sock,
gint first,
gint last);
#if 0
static gint imap_search (gint sock,
static gint imap_search (SockInfo *sock,
GSList *numlist);
#endif
static gint imap_get_message (gint sock,
static gint imap_get_message (SockInfo *sock,
gint num,
const gchar *filename);
static gint imap_copy_message (gint sock,
static gint imap_copy_message (SockInfo *sock,
gint num,
const gchar *destfolder);
static gint imap_store (gint sock,
static gint imap_store (SockInfo *sock,
gint first,
gint last,
gchar *sub_cmd);
@ -92,29 +92,29 @@ static gint imap_set_article_flags (IMAPSession *session,
gboolean is_set);
static gint imap_expunge (IMAPSession *session);
static gchar *imap_parse_atom (gint sock,
gchar *src,
gchar *dest,
gchar *orig_buf);
static gchar *imap_parse_one_address (gint sock,
gchar *start,
gchar *out_from_str,
gchar *out_fromname_str,
gchar *orig_buf);
static gchar *imap_parse_address (gint sock,
gchar *start,
gchar **out_from_str,
gchar **out_fromname_str,
gchar *orig_buf);
static gchar *imap_parse_atom (SockInfo *sock,
gchar *src,
gchar *dest,
gchar *orig_buf);
static gchar *imap_parse_one_address (SockInfo *sock,
gchar *start,
gchar *out_from_str,
gchar *out_fromname_str,
gchar *orig_buf);
static gchar *imap_parse_address (SockInfo *sock,
gchar *start,
gchar **out_from_str,
gchar **out_fromname_str,
gchar *orig_buf);
static MsgFlags imap_parse_flags (const gchar *flag_str);
static MsgInfo *imap_parse_envelope (gint sock,
gchar *line_str);
static MsgInfo *imap_parse_envelope (SockInfo *sock,
gchar *line_str);
static gint imap_ok (gint sock,
static gint imap_ok (SockInfo *sock,
GPtrArray *argbuf);
static void imap_gen_send (gint sock,
static void imap_gen_send (SockInfo *sock,
const gchar *format, ...);
static gint imap_gen_recv (gint sock,
static gint imap_gen_recv (SockInfo *sock,
gchar *buf,
gint size);
@ -157,7 +157,7 @@ Session *imap_session_new(const gchar *server, gushort port,
{
gchar buf[IMAPBUFSIZE];
IMAPSession *session;
gint imap_sock;
SockInfo *imap_sock;
g_return_val_if_fail(server != NULL, NULL);
@ -168,7 +168,7 @@ Session *imap_session_new(const gchar *server, gushort port,
return NULL;
if (imap_auth(imap_sock, user, pass) != IMAP_SUCCESS) {
imap_logout(imap_sock);
close(imap_sock);
sock_close(imap_sock);
return NULL;
}
@ -188,7 +188,8 @@ Session *imap_session_new(const gchar *server, gushort port,
void imap_session_destroy(IMAPSession *session)
{
close(SESSION(session)->sock);
sock_close(SESSION(session)->sock);
SESSION(session)->sock = NULL;
g_free(session->mbox);
@ -222,8 +223,8 @@ GSList *imap_get_msg_list(Folder *folder, FolderItem *item, gboolean use_cache)
item->last_num = procmsg_get_last_num_in_cache(mlist);
procmsg_set_flags(mlist, item);
} else {
gint ok, exists = 0, recent = 0, unseen = 0, begin = 1;
gulong uid = 0, last_uid = item->mtime;
gint ok, exists = 0, recent = 0, unseen = 0, begin = 1;
gulong uid = 0, last_uid = item->mtime;
ok = imap_select(SESSION(session)->sock, item->path,
&exists, &recent, &unseen, &uid);
@ -619,30 +620,27 @@ static void imap_delete_all_messages(FolderItem *item)
}
static gint imap_open(const gchar *server, gushort port, gchar *buf)
static SockInfo *imap_open(const gchar *server, gushort port, gchar *buf)
{
SockInfo *sockinfo;
gint sock;
SockInfo *sock;
if ((sockinfo = sock_connect(server, port)) == NULL) {
if ((sock = sock_connect(server, port)) == NULL) {
log_warning(_("Can't connect to IMAP4 server: %s:%d\n"),
server, port);
return -1;
return NULL;
}
sock = sockinfo->sock;
sock_sockinfo_free(sockinfo);
imap_cmd_count = 0;
if (imap_noop(sock) != IMAP_SUCCESS) {
sock_close(sock);
return -1;
return NULL;
}
return sock;
}
static gint imap_auth(gint sock, const gchar *user, const gchar *pass)
static gint imap_auth(SockInfo *sock, const gchar *user, const gchar *pass)
{
gint ok;
GPtrArray *argbuf;
@ -657,19 +655,19 @@ static gint imap_auth(gint sock, const gchar *user, const gchar *pass)
return ok;
}
static gint imap_logout(gint sock)
static gint imap_logout(SockInfo *sock)
{
imap_gen_send(sock, "LOGOUT");
return imap_ok(sock, NULL);
}
static gint imap_noop(gint sock)
static gint imap_noop(SockInfo *sock)
{
imap_gen_send(sock, "NOOP");
return imap_ok(sock, NULL);
}
static gint imap_select(gint sock, const gchar *folder,
static gint imap_select(SockInfo *sock, const gchar *folder,
gint *exists, gint *recent, gint *unseen, gulong *uid)
{
gint ok;
@ -741,7 +739,7 @@ static gchar *strchr_cpy(const gchar *src, gchar ch, gchar *dest, gint len)
return tmp + 1;
}
static gint imap_get_message(gint sock, gint num, const gchar *filename)
static gint imap_get_message(SockInfo *sock, gint num, const gchar *filename)
{
gint ok;
gchar buf[IMAPBUFSIZE];
@ -782,7 +780,7 @@ static gint imap_get_message(gint sock, gint num, const gchar *filename)
return ok;
}
static gint imap_copy_message(gint sock, gint num, const gchar *destfolder)
static gint imap_copy_message(SockInfo *sock, gint num, const gchar *destfolder)
{
gint ok;
@ -798,7 +796,7 @@ static gint imap_copy_message(gint sock, gint num, const gchar *destfolder)
return ok;
}
static gchar *imap_parse_atom(gint sock, gchar *src, gchar *dest,
static gchar *imap_parse_atom(SockInfo *sock, gchar *src, gchar *dest,
gchar *orig_buf)
{
gchar *cur_pos = src;
@ -834,7 +832,7 @@ static gchar *imap_parse_atom(gint sock, gchar *src, gchar *dest,
return cur_pos;
}
static gchar *imap_parse_one_address(gint sock, gchar *start,
static gchar *imap_parse_one_address(SockInfo *sock, gchar *start,
gchar *out_from_str,
gchar *out_fromname_str,
gchar *orig_buf)
@ -870,7 +868,7 @@ static gchar *imap_parse_one_address(gint sock, gchar *start,
return cur_pos + 1;
}
static gchar *imap_parse_address(gint sock, gchar *start,
static gchar *imap_parse_address(SockInfo *sock, gchar *start,
gchar **out_from_str,
gchar **out_fromname_str,
gchar *orig_buf)
@ -944,7 +942,7 @@ static MsgFlags imap_parse_flags(const gchar *flag_str)
return flags;
}
static MsgInfo *imap_parse_envelope(gint sock, gchar *line_str)
static MsgInfo *imap_parse_envelope(SockInfo *sock, gchar *line_str)
{
MsgInfo *msginfo;
gchar buf[IMAPBUFSIZE];
@ -1079,7 +1077,7 @@ static MsgInfo *imap_parse_envelope(gint sock, gchar *line_str)
return msginfo;
}
gint imap_get_envelope(gint sock, gint first, gint last)
gint imap_get_envelope(SockInfo *sock, gint first, gint last)
{
imap_gen_send(sock, "FETCH %d:%d (FLAGS RFC822.SIZE ENVELOPE)",
first, last);
@ -1087,7 +1085,7 @@ gint imap_get_envelope(gint sock, gint first, gint last)
return IMAP_SUCCESS;
}
static gint imap_store(gint sock, gint first, gint last, gchar *sub_cmd)
static gint imap_store(SockInfo *sock, gint first, gint last, gchar *sub_cmd)
{
gint ok;
GPtrArray *argbuf;
@ -1156,7 +1154,7 @@ static gint imap_expunge(IMAPSession *session)
return IMAP_SUCCESS;
}
static gint imap_ok(gint sock, GPtrArray *argbuf)
static gint imap_ok(SockInfo *sock, GPtrArray *argbuf)
{
gint ok;
gchar buf[IMAPBUFSIZE];
@ -1198,7 +1196,7 @@ static gchar *search_array_contain_str(GPtrArray *array, gchar *str)
return NULL;
}
static void imap_gen_send(gint sock, const gchar *format, ...)
static void imap_gen_send(SockInfo *sock, const gchar *format, ...)
{
gchar buf[IMAPBUFSIZE];
gchar tmp[IMAPBUFSIZE];
@ -1221,7 +1219,7 @@ static void imap_gen_send(gint sock, const gchar *format, ...)
sock_write(sock, buf, strlen(buf));
}
static gint imap_gen_recv(gint sock, gchar *buf, gint size)
static gint imap_gen_recv(SockInfo *sock, gchar *buf, gint size)
{
if (sock_read(sock, buf, size) == -1)
return IMAP_SOCKET;

View file

@ -78,12 +78,12 @@ gchar *imap_fetch_msg (Folder *folder,
gint num);
gint imap_move_msg (Folder *folder,
FolderItem *dest,
MsgInfo *msginfo);
FolderItem *dest,
MsgInfo *msginfo);
gint imap_move_msgs_with_dest (Folder *folder,
FolderItem *dest,
GSList *msglist);
gint imap_move_msgs_with_dest (Folder *folder,
FolderItem *dest,
GSList *msglist);
gint imap_remove_msg (Folder *folder,
FolderItem *item,
gint num);

View file

@ -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
@ -61,6 +61,17 @@
#include "automaton.h"
#include "folder.h"
#include "pixmaps/continue.xpm"
#include "pixmaps/complete.xpm"
#include "pixmaps/error.xpm"
GdkPixmap *currentxpm;
GdkBitmap *currentxpmmask;
GdkPixmap *errorxpm;
GdkBitmap *errorxpmmask;
GdkPixmap *okxpm;
GdkBitmap *okxpmmask;
#define MSGBUFSIZE 8192
static void inc_finished (MainWindow *mainwin);
@ -76,7 +87,7 @@ static Pop3State *inc_pop3_state_new (PrefsAccount *account);
static void inc_pop3_state_destroy (Pop3State *state);
static void inc_start (IncProgressDialog *inc_dialog);
static IncState inc_pop3_session_do (IncSession *session);
static gint pop3_automaton_terminate (gint source,
static gint pop3_automaton_terminate (SockInfo *source,
Automaton *atm);
static GHashTable *inc_get_uidl_table (PrefsAccount *ac_prefs);
@ -95,6 +106,7 @@ static gint inc_spool (void);
static gint get_spool (FolderItem *dest,
const gchar *mbox);
static void inc_finished(MainWindow *mainwin)
{
FolderItem *item;
@ -152,6 +164,7 @@ static void inc_account_mail(PrefsAccount *account, MainWindow *mainwin)
{
IncProgressDialog *inc_dialog;
IncSession *session;
gchar *text[3];
session = inc_session_new(account);
if (!session) return;
@ -161,6 +174,11 @@ static void inc_account_mail(PrefsAccount *account, MainWindow *mainwin)
inc_dialog->mainwin = mainwin;
session->data = inc_dialog;
text[0] = NULL;
text[1] = account->account_name;
text[2] = _("Standby");
gtk_clist_append(GTK_CLIST(inc_dialog->dialog->clist), text);
inc_start(inc_dialog);
}
@ -194,7 +212,14 @@ void inc_all_account_mail(MainWindow *mainwin)
inc_dialog->mainwin = mainwin;
for (list = queue_list; list != NULL; list = list->next) {
IncSession *session = list->data;
gchar *text[3];
session->data = inc_dialog;
text[0] = NULL;
text[1] = session->pop3_state->ac_prefs->account_name;
text[2] = _("Standby");
gtk_clist_append(GTK_CLIST(inc_dialog->dialog->clist), text);
}
inc_start(inc_dialog);
@ -220,6 +245,13 @@ static IncProgressDialog *inc_progress_dialog_create(void)
progress_dialog_set_value(progress, 0.0);
gtk_widget_show(progress->window);
PIXMAP_CREATE(progress->clist, okxpm, okxpmmask, complete_xpm);
PIXMAP_CREATE(progress->clist,
currentxpm, currentxpmmask, continue_xpm);
PIXMAP_CREATE(progress->clist, errorxpm, errorxpmmask, error_xpm);
gtk_widget_show_now(progress->window);
dialog->dialog = progress;
@ -308,8 +340,10 @@ static void inc_pop3_state_destroy(Pop3State *state)
static void inc_start(IncProgressDialog *inc_dialog)
{
IncSession *session;
GtkCList *clist = GTK_CLIST(inc_dialog->dialog->clist);
Pop3State *pop3_state;
IncState inc_state;
gint num = 0;
while (inc_dialog->queue_list != NULL) {
session = inc_dialog->queue_list->data;
@ -349,9 +383,20 @@ static void inc_start(IncProgressDialog *inc_dialog)
}
}
gtk_clist_set_pixmap(clist, num, 0, currentxpm, currentxpmmask);
gtk_clist_set_text(clist, num, 2, _("Retrieving"));
/* begin POP3 session */
inc_state = inc_pop3_session_do(session);
if (inc_state == INC_SUCCESS || inc_state == INC_CANCEL) {
gtk_clist_set_pixmap(clist, num, 0, okxpm, okxpmmask);
gtk_clist_set_text(clist, num, 2, _("Done"));
} else {
gtk_clist_set_pixmap(clist, num, 0, errorxpm, errorxpmmask);
gtk_clist_set_text(clist, num, 2, _("Error"));
}
if (pop3_state->error_val == PS_AUTHFAIL) {
manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL);
alertpanel_error
@ -382,6 +427,8 @@ static void inc_start(IncProgressDialog *inc_dialog)
inc_session_destroy(session);
inc_dialog->queue_list =
g_list_remove(inc_dialog->queue_list, session);
num++;
}
while (inc_dialog->queue_list != NULL) {
@ -394,6 +441,7 @@ static void inc_start(IncProgressDialog *inc_dialog)
inc_progress_dialog_destroy(inc_dialog);
}
static IncState inc_pop3_session_do(IncSession *session)
{
Pop3State *pop3_state = session->pop3_state;
@ -463,21 +511,24 @@ static IncState inc_pop3_session_do(IncSession *session)
alertpanel_error(_("Can't connect to POP3 server: %s:%d"),
server, port);
manage_window_focus_out(inc_dialog->dialog->window, NULL, NULL);
pop3_automaton_terminate(-1, atm);
pop3_automaton_terminate(NULL, atm);
automaton_destroy(atm);
return pop3_state->inc_state;
return INC_ERROR;
}
/* :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;
#if USE_THREADS
atm->timeout_tag = gtk_timeout_add
(TIMEOUT_ITV, (GtkFunction)connection_check_cb, atm);
#else
atm->tag = gdk_input_add(sockinfo->sock,
atm->state[atm->num].condition,
automaton_input_cb, atm);
atm->tag = sock_gdk_input_add(sockinfo,
atm->state[atm->num].condition,
automaton_input_cb, atm);
#endif
gtk_main();
@ -485,13 +536,12 @@ static IncState inc_pop3_session_do(IncSession *session)
#if USE_THREADS
//pthread_join(sockinfo->connect_thr, NULL);
#endif
sock_sockinfo_free(sockinfo);
automaton_destroy(atm);
return pop3_state->inc_state;
}
static gint pop3_automaton_terminate(gint source, Automaton *atm)
static gint pop3_automaton_terminate(SockInfo *source, Automaton *atm)
{
if (atm->tag > 0) {
gdk_input_remove(atm->tag);
@ -501,7 +551,7 @@ static gint pop3_automaton_terminate(gint source, Automaton *atm)
gtk_timeout_remove(atm->timeout_tag);
atm->timeout_tag = 0;
}
if (source > 0) {
if (source) {
sock_close(source);
gtk_main_quit();
}
@ -725,7 +775,7 @@ static void inc_cancel(GtkWidget *widget, gpointer data)
#endif
session->pop3_state->inc_state = INC_CANCEL;
pop3_automaton_terminate(sockinfo->sock, session->atm);
pop3_automaton_terminate(sockinfo, session->atm);
}
static gint inc_spool(void)
@ -786,4 +836,4 @@ static gint get_spool(FolderItem *dest, const gchar *mbox)
}
return msgs;
}
}

View file

@ -61,6 +61,7 @@
#include "procmsg.h"
#include "inc.h"
#include "import.h"
#include "manage_window.h"
#include "alertpanel.h"
#include "addressbook.h"
#include "compose.h"
@ -70,6 +71,7 @@
#include "gtkutils.h"
gchar *prog_version;
gchar *startup_dir;
gboolean debug_mode = FALSE;
static gint lock_socket = -1;
@ -147,11 +149,11 @@ int main(int argc, char *argv[])
#endif
/* parse gtkrc files */
userrc = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc",
userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc",
NULL);
gtk_rc_parse(userrc);
g_free(userrc);
userrc = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, ".gtk",
userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtk",
G_DIR_SEPARATOR_S, "gtkrc", NULL);
gtk_rc_parse(userrc);
g_free(userrc);
@ -166,10 +168,11 @@ int main(int argc, char *argv[])
g_free(userrc);
prog_version = PROG_VERSION;
startup_dir = g_get_current_dir();
parse_cmd_opt(argc, argv);
CHDIR_RETURN_VAL_IF_FAIL(g_get_home_dir(), 1);
CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
/* check and create unix domain socket */
lock_socket = prohibit_duplicate_launch();
@ -196,6 +199,13 @@ int main(int argc, char *argv[])
srandom((gint)time(NULL));
#if USE_GPGME
if (gpgme_check_engine()) { /* Also does some gpgme init */
rfc2015_disable_all();
debug_print("gpgme_engine_version:\n%s\n",
gpgme_get_engine_info());
alertpanel_warning(_("GnuPG is not installed properly.\n"
"OpenPGP support disabled."));
}
gpgme_register_idle(idle_function_for_gpgme);
#endif
@ -282,6 +292,17 @@ static void parse_cmd_opt(int argc, char *argv[])
}
}
static gint get_queued_message_num(void)
{
FolderItem *queue;
queue = folder_get_default_queue();
g_return_val_if_fail(queue != NULL, -1);
folder_item_scan(queue);
return queue->total;
}
void app_will_exit(GtkWidget *widget, gpointer data)
{
MainWindow *mainwin = data;
@ -292,6 +313,15 @@ void app_will_exit(GtkWidget *widget, gpointer data)
_("Composing message exists. Really quit?"),
_("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
return;
manage_window_focus_in(mainwin->window, NULL, NULL);
}
if (prefs_common.warn_queued_on_exit && get_queued_message_num() > 0) {
if (alertpanel(_("Queued messages"),
_("Some unsent messages are queued. Exit now?"),
_("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
return;
manage_window_focus_in(mainwin->window, NULL, NULL);
}
if (prefs_common.clean_on_exit)
@ -317,7 +347,7 @@ void app_will_exit(GtkWidget *widget, gpointer data)
/* delete unix domain socket */
gdk_input_remove(lock_socket_tag);
sock_close(lock_socket);
fd_close(lock_socket);
filename = get_socket_name();
unlink(filename);
@ -351,10 +381,10 @@ static gint prohibit_duplicate_launch(void)
gchar *path;
path = get_socket_name();
uxsock = sock_connect_unix(path);
uxsock = fd_connect_unix(path);
if (uxsock < 0) {
unlink(path);
return sock_open_unix(path);
return fd_open_unix(path);
}
/* remote command mode */
@ -362,9 +392,9 @@ static gint prohibit_duplicate_launch(void)
debug_print(_("another Sylpheed is already running.\n"));
if (cmd.receive_all)
sock_write(uxsock, "receive_all\n", 12);
fd_write(uxsock, "receive_all\n", 12);
else if (cmd.receive)
sock_write(uxsock, "receive\n", 8);
fd_write(uxsock, "receive\n", 8);
else if (cmd.compose) {
gchar *compose_str;
@ -373,12 +403,12 @@ static gint prohibit_duplicate_launch(void)
else
compose_str = g_strdup("compose\n");
sock_write(uxsock, compose_str, strlen(compose_str));
fd_write(uxsock, compose_str, strlen(compose_str));
g_free(compose_str);
} else
sock_write(uxsock, "popup\n", 6);
fd_write(uxsock, "popup\n", 6);
sock_close(uxsock);
fd_close(uxsock);
return -1;
}
@ -390,9 +420,9 @@ static void lock_socket_input_cb(gpointer data,
gint sock;
gchar buf[BUFFSIZE];
sock = sock_accept(source);
sock_read(sock, buf, sizeof(buf));
sock_close(sock);
sock = fd_accept(source);
fd_read(sock, buf, sizeof(buf));
fd_close(sock);
if (!strncmp(buf, "popup", 5)){
main_window_popup(mainwin);
@ -421,3 +451,4 @@ static void open_compose_new_with_recipient(const gchar *address)
else
compose_new(NULL);
}

View file

@ -24,6 +24,7 @@
#include <gtk/gtkwidget.h>
extern gchar *prog_version;
extern gchar *startup_dir;
extern gboolean debug_mode;
void app_will_exit (GtkWidget *widget, gpointer data);

View file

@ -783,6 +783,7 @@ void main_window_reflect_prefs_all(void)
}
summary_change_display_item(mainwin->summaryview);
summary_redisplay_msg(mainwin->summaryview);
headerview_set_visibility(mainwin->messageview->headerview,
prefs_common.display_header_pane);
}
@ -942,6 +943,7 @@ void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
_("Empty all messages in trash?"),
_("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
return;
manage_window_focus_in(mainwin->window, NULL, NULL);
}
procmsg_empty_trash();
@ -1646,29 +1648,15 @@ static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
summary_print(mainwin->summaryview);
}
static gint queued_messages(void)
{
FolderItem *queue = folder_get_default_queue();
folder_item_scan(queue);
return queue->total;
}
static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
{
if (prefs_common.confirm_on_exit) {
if (alertpanel(_("Exit"), _("Exit this program?"),
_("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
return;
manage_window_focus_in(mainwin->window, NULL, NULL);
}
if (prefs_common.warn_queued_on_exit && queued_messages() > 0) {
if (alertpanel(_("Queued messages"),
_("Some unsent messages are queued. Exit now?"),
_("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
return;
}
manage_window_focus_in(mainwin->window, NULL, NULL);
app_will_exit(widget, mainwin);
}

View file

@ -394,7 +394,10 @@ gint export_to_mbox(FolderItem *src, const gchar *mbox)
msginfo = (MsgInfo *)cur->data;
msg_fp = procmsg_open_message(msginfo);
if (!msg_fp) continue;
if (!msg_fp) {
procmsg_msginfo_free(msginfo);
continue;
}
strncpy2(buf,
msginfo->from ? msginfo->from :

View file

@ -1,42 +1,51 @@
/* MD5.H - header file for MD5C.C
/* md5.h - MD5 Message-Digest Algorithm
* Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
*
* according to the definition of MD5 in RFC 1321 from April 1992.
* NOTE: This is *not* the same file as the one from glibc
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
#ifndef _MD5_HDR_
#define _MD5_HDR_
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
#include "utils.h"
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
typedef struct { /* Hmm, should be private */
u32 A,B,C,D;
u32 nblocks;
unsigned char buf[64];
int count;
int finalized;
} MD5_CONTEXT;
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
typedef MD5_CONTEXT MD5_CTX;
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
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);
#ifndef MD5_H__
#define MD5_H__
void md5_hex_digest(char *hexdigest, const unsigned char *s);
#include "md5global.h"
void md5_hmac(unsigned char *digest,
const unsigned char* text, int text_len,
const unsigned char* key, int key_len);
void md5_hex_hmac(char *hexdigest,
const unsigned char* text, int text_len,
const unsigned char* key, int key_len);
/* MD5 context. */
typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
#endif /* _MD5_HDR_ */
void MD5Init PROTO_LIST ((MD5_CTX *));
void MD5Update PROTO_LIST
((MD5_CTX *, unsigned char *, unsigned int));
void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
#endif /* MD5_H__ */

View file

@ -1,334 +1,434 @@
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
/* md5.c - MD5 Message-Digest Algorithm
* Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
*
* according to the definition of MD5 in RFC 1321 from April 1992.
* NOTE: This is *not* the same file as the one from glibc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
/* heavily modified for GnuPG by <werner.koch@guug.de> */
/* modified again for Sylpheed by <wk@gnupg.org> 2001-02-11 */
/* Test values:
* "" D4 1D 8C D9 8F 00 B2 04 E9 80 09 98 EC F8 42 7E
* "a" 0C C1 75 B9 C0 F1 B6 A8 31 C3 99 E2 69 77 26 61
* "abc 90 01 50 98 3C D2 4F B0 D6 96 3F 7D 28 E1 7F 72
* "message digest" F9 6B 69 7D 7C B7 93 8D 52 5A 2F 31 AA F1 61 D0
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
#include "config.h"
#include "md5global.h"
#include "utils.h"
#include "md5.h"
/* Constants for MD5Transform routine.
/****************
* Rotate a 32 bit integer by n bytes
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
static void Encode PROTO_LIST
((unsigned char *, UINT4 *, unsigned int));
static void Decode PROTO_LIST
((UINT4 *, unsigned char *, unsigned int));
static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
void MD5Init (context)
MD5_CTX *context; /* context */
#if defined(__GNUC__) && defined(__i386__)
static inline u32
rol( u32 x, int n)
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants.
__asm__("roll %%cl,%0"
:"=r" (x)
:"0" (x),"c" (n));
return x;
}
#else
#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
#endif
void
md5_init( MD5_CONTEXT *ctx )
{
ctx->A = 0x67452301;
ctx->B = 0xefcdab89;
ctx->C = 0x98badcfe;
ctx->D = 0x10325476;
ctx->nblocks = 0;
ctx->count = 0;
ctx->finalized = 0;
}
/* These are the four functions used in the four steps of the MD5 algorithm
and defined in the RFC 1321. The first function is a little bit optimized
(as found in Colin Plumbs public domain implementation). */
/* #define FF(b, c, d) ((b & c) | (~b & d)) */
#define FF(b, c, d) (d ^ (b & (c ^ d)))
#define FG(b, c, d) FF (d, b, c)
#define FH(b, c, d) (b ^ c ^ d)
#define FI(b, c, d) (c ^ (b | ~d))
/****************
* transform n*64 bytes
*/
static void
transform( MD5_CONTEXT *ctx, const unsigned char *data )
{
u32 correct_words[16];
u32 A = ctx->A;
u32 B = ctx->B;
u32 C = ctx->C;
u32 D = ctx->D;
u32 *cwp = correct_words;
#ifdef BIG_ENDIAN_HOST
{ int i;
const unsigned char *p2, *p1;
for(i=0, p1=data, p2=(unsigned char*)correct_words; i < 16; i++, p2 += 4 ) {
p2[3] = *p1++;
p2[2] = *p1++;
p2[1] = *p1++;
p2[0] = *p1++;
}
}
#else
memcpy( correct_words, data, 64 );
#endif
#define OP(a, b, c, d, s, T) \
do \
{ \
a += FF (b, c, d) + (*cwp++) + T; \
a = rol(a, s); \
a += b; \
} \
while (0)
/* Before we start, one word about the strange constants.
They are defined in RFC 1321 as
T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
*/
/* Round 1. */
OP (A, B, C, D, 7, 0xd76aa478);
OP (D, A, B, C, 12, 0xe8c7b756);
OP (C, D, A, B, 17, 0x242070db);
OP (B, C, D, A, 22, 0xc1bdceee);
OP (A, B, C, D, 7, 0xf57c0faf);
OP (D, A, B, C, 12, 0x4787c62a);
OP (C, D, A, B, 17, 0xa8304613);
OP (B, C, D, A, 22, 0xfd469501);
OP (A, B, C, D, 7, 0x698098d8);
OP (D, A, B, C, 12, 0x8b44f7af);
OP (C, D, A, B, 17, 0xffff5bb1);
OP (B, C, D, A, 22, 0x895cd7be);
OP (A, B, C, D, 7, 0x6b901122);
OP (D, A, B, C, 12, 0xfd987193);
OP (C, D, A, B, 17, 0xa679438e);
OP (B, C, D, A, 22, 0x49b40821);
#undef OP
#define OP(f, a, b, c, d, k, s, T) \
do \
{ \
a += f (b, c, d) + correct_words[k] + T; \
a = rol(a, s); \
a += b; \
} \
while (0)
/* Round 2. */
OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
OP (FG, D, A, B, C, 6, 9, 0xc040b340);
OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
OP (FG, D, A, B, C, 10, 9, 0x02441453);
OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
/* Round 3. */
OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
OP (FH, D, A, B, C, 8, 11, 0x8771f681);
OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
OP (FH, B, C, D, A, 6, 23, 0x04881d05);
OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
/* Round 4. */
OP (FI, A, B, C, D, 0, 6, 0xf4292244);
OP (FI, D, A, B, C, 7, 10, 0x432aff97);
OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
OP (FI, C, D, A, B, 6, 15, 0xa3014314);
OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
/* Put checksum in context given as argument. */
ctx->A += A;
ctx->B += B;
ctx->C += C;
ctx->D += D;
}
/* The routine updates the message-digest context to
* account for the presence of each of the characters inBuf[0..inLen-1]
* in the message whose digest is being computed.
*/
void
md5_update( MD5_CONTEXT *hd, const unsigned char *inbuf, size_t inlen)
{
if( hd->count == 64 ) { /* flush the buffer */
transform( hd, hd->buf );
hd->count = 0;
hd->nblocks++;
}
if( !inbuf )
return;
if( hd->count ) {
for( ; inlen && hd->count < 64; inlen-- )
hd->buf[hd->count++] = *inbuf++;
md5_update( hd, NULL, 0 );
if( !inlen )
return;
}
while( inlen >= 64 ) {
transform( hd, inbuf );
hd->count = 0;
hd->nblocks++;
inlen -= 64;
inbuf += 64;
}
for( ; inlen && hd->count < 64; inlen-- )
hd->buf[hd->count++] = *inbuf++;
}
/* The routine final terminates the message-digest computation and
* ends with the desired message digest in mdContext->digest[0...15].
* The handle is prepared for a new MD5 cycle.
* Returns 16 bytes representing the digest.
*/
static void
do_final( MD5_CONTEXT *hd )
{
u32 t, msb, lsb;
unsigned char *p;
md5_update(hd, NULL, 0); /* flush */;
msb = 0;
t = hd->nblocks;
if( (lsb = t << 6) < t ) /* multiply by 64 to make a byte count */
msb++;
msb += t >> 26;
t = lsb;
if( (lsb = t + hd->count) < t ) /* add the count */
msb++;
t = lsb;
if( (lsb = t << 3) < t ) /* multiply by 8 to make a bit count */
msb++;
msb += t >> 29;
if( hd->count < 56 ) { /* enough room */
hd->buf[hd->count++] = 0x80; /* pad */
while( hd->count < 56 )
hd->buf[hd->count++] = 0; /* pad */
}
else { /* need one extra block */
hd->buf[hd->count++] = 0x80; /* pad character */
while( hd->count < 64 )
hd->buf[hd->count++] = 0;
md5_update(hd, NULL, 0); /* flush */;
memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
}
/* append the 64 bit count */
hd->buf[56] = lsb ;
hd->buf[57] = lsb >> 8;
hd->buf[58] = lsb >> 16;
hd->buf[59] = lsb >> 24;
hd->buf[60] = msb ;
hd->buf[61] = msb >> 8;
hd->buf[62] = msb >> 16;
hd->buf[63] = msb >> 24;
transform( hd, hd->buf );
p = hd->buf;
#ifdef BIG_ENDIAN_HOST
#define X(a) do { *p++ = hd->##a ; *p++ = hd->##a >> 8; \
*p++ = hd->##a >> 16; *p++ = hd->##a >> 24; } while(0)
#else /* little endian */
/*#define X(a) do { *(u32*)p = hd->##a ; p += 4; } while(0)*/
/* Unixware's cpp doesn't like the above construct so we do it his way:
* (reported by Allan Clark) */
#define X(a) do { *(u32*)p = (*hd).a ; p += 4; } while(0)
#endif
X(A);
X(B);
X(C);
X(D);
#undef X
hd->finalized = 1;
}
void
md5_final ( unsigned char *digest, MD5_CONTEXT *ctx )
{
if ( !ctx->finalized )
do_final (ctx);
memcpy (digest, ctx->buf, 16);
}
/*
* Creates a MD5 digest in hex fomrat (lowercase letters) from the
* string S. hextdigest but be buffer of at lease 33 bytes!
*/
void
md5_hex_digest (char *hexdigest, const unsigned char *s)
{
int i;
MD5_CTX context;
unsigned char digest[16];
md5_init(&context);
md5_update(&context, s, strlen(s));
md5_final(digest, &context);
for (i = 0; i < 16; i++)
sprintf(hexdigest+2*i, "%02x", digest[i]);
}
/*
** Function: md5_hmac
** taken from the file rfc2104.txt
** written by Martin Schaaf <mascha@ma-scha.de>
*/
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/* MD5 block update operation. Continues an MD5 message-digest
operation, processing another message block, and updating the
context.
*/
void MD5Update (context, input, inputLen)
MD5_CTX *context; /* context */
unsigned char *input; /* input block */
unsigned int inputLen; /* length of input block */
void
md5_hmac(unsigned char *digest,
const unsigned char* text, int text_len,
const unsigned char* key, int key_len )
{
unsigned int i, index, partLen;
MD5_CTX context;
unsigned char k_ipad[64]; /* inner padding -
* key XORd with ipad
*/
unsigned char k_opad[64]; /* outer padding -
* key XORd with opad
*/
/* unsigned char tk[16]; */
int i;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* start out by storing key in pads */
memset( k_ipad, 0, sizeof k_ipad);
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 tctx;
md5_init(&tctx);
md5_update(&tctx, key, key_len);
md5_final(k_ipad, &tctx);
md5_final(k_opad, &tctx);
}
else {
memcpy(k_ipad, key, key_len);
memcpy(k_opad, key, key_len);
}
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
/*
* the HMAC_MD5 transform looks like:
*
* MD5(K XOR opad, MD5(K XOR ipad, text))
*
* where K is an n byte key
* ipad is the byte 0x36 repeated 64 times
* opad is the byte 0x5c repeated 64 times
* and text is the data being protected
*/
partLen = 64 - index;
/* Transform as many times as possible.
*/
if (inputLen >= partLen) {
MD5_memcpy
((POINTER)&context->buffer[index], (POINTER)input, partLen);
MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform (context->state, &input[i]);
index = 0;
}
else
i = 0;
/* Buffer remaining input */
MD5_memcpy
((POINTER)&context->buffer[index], (POINTER)&input[i],
inputLen-i);
/* XOR key with ipad and opad values */
for (i=0; i<64; i++) {
k_ipad[i] ^= 0x36;
k_opad[i] ^= 0x5c;
}
/*
* perform inner MD5
*/
md5_init(&context); /* init context for 1st
* pass */
md5_update(&context, k_ipad, 64); /* start with inner pad */
md5_update(&context, text, text_len); /* then text of datagram */
md5_final(digest, &context); /* finish up 1st pass */
/*
* perform outer MD5
*/
md5_init(&context); /* init context for 2nd
* pass */
md5_update(&context, k_opad, 64); /* start with outer pad */
md5_update(&context, digest, 16); /* then results of 1st
* hash */
md5_final(digest, &context); /* finish up 2nd pass */
}
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
void MD5Final (digest, context)
unsigned char digest[16]; /* message digest */
MD5_CTX *context; /* context */
void
md5_hex_hmac(char *hexdigest,
const unsigned char* text, int text_len,
const unsigned char* key, int key_len )
{
unsigned char bits[8];
unsigned int index, padLen;
unsigned char digest[16];
int i;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64.
*/
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD5Update (context, PADDING, padLen);
/* Append length (before padding) */
MD5Update (context, bits, 8);
/* Store state in digest */
Encode (digest, context->state, 16);
/* Zeroize sensitive information.
*/
MD5_memset ((POINTER)context, 0, sizeof (*context));
}
/* MD5 basic transformation. Transforms state based on block.
*/
static void MD5Transform (state, block)
UINT4 state[4];
unsigned char block[64];
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information.
*/
MD5_memset ((POINTER)x, 0, sizeof (x));
}
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
a multiple of 4.
*/
static void Encode (output, input, len)
unsigned char *output;
UINT4 *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
}
}
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
a multiple of 4.
*/
static void Decode (output, input, len)
UINT4 *output;
unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
/* Note: Replace "for loop" with standard memcpy if possible.
*/
static void MD5_memcpy (output, input, len)
POINTER output;
POINTER input;
unsigned int len;
{
unsigned int i;
for (i = 0; i < len; i++)
output[i] = input[i];
}
/* Note: Replace "for loop" with standard memset if possible.
*/
static void MD5_memset (output, value, len)
POINTER output;
int value;
unsigned int len;
{
unsigned int i;
for (i = 0; i < len; i++)
((char *)output)[i] = (char)value;
md5_hmac( digest, text, text_len, key, key_len);
for (i = 0; i < 16; i++)
sprintf(hexdigest+2*i, "%02x", digest[i]);
}

View file

@ -632,7 +632,7 @@ gint mh_create_tree(Folder *folder)
g_return_val_if_fail(folder != NULL, -1);
CHDIR_RETURN_VAL_IF_FAIL(g_get_home_dir(), -1);
CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), -1);
rootpath = LOCAL_FOLDER(folder)->rootpath;
MAKE_DIR_IF_NOT_EXIST(rootpath);
CHDIR_RETURN_VAL_IF_FAIL(rootpath, -1);
@ -885,6 +885,30 @@ static MsgInfo *mh_parse_msg(const gchar *file, FolderItem *item)
return msginfo;
}
static gboolean mh_is_maildir_one(const gchar *path, const gchar *dir)
{
char *entry;
gboolean result;
entry = g_strconcat(path, G_DIR_SEPARATOR_S, dir, NULL);
result = is_dir_exist(entry);
g_free(entry);
return result;
}
/*
* check whether PATH is a Maildir style mailbox.
* This is the case if the 3 subdir: new, cur, tmp are existing.
* This functon assumes that entry is an directory
*/
static gboolean mh_is_maildir(const gchar *path)
{
return mh_is_maildir_one(path, "new") &&
mh_is_maildir_one(path, "cur") &&
mh_is_maildir_one(path, "tmp");
}
static void mh_scan_tree_recursive(FolderItem *item)
{
DIR *dp;
@ -927,6 +951,11 @@ static void mh_scan_tree_recursive(FolderItem *item)
if (S_ISDIR(s.st_mode)) {
FolderItem *new_item;
if (mh_is_maildir(entry)) {
g_free(entry);
continue;
}
new_item = folder_item_new(d->d_name, entry);
folder_item_append(item, new_item);
if (!item->path) {

View file

@ -242,7 +242,7 @@ static void set_unchecked_signature(MimeInfo *mimeinfo)
g_free(sig_partinfo->sigstatus_full);
sig_partinfo->sigstatus_full = NULL;
}
#endif /*USE_GPGME*/
#endif /* USE_GPGME */
void mimeview_show_message(MimeView *mimeview, MimeInfo *mimeinfo,
const gchar *file)
@ -855,4 +855,4 @@ static void mimeview_check_signature(MimeView *mimeview)
mimeview_update_names(mimeview);
mimeview_update_signature_info(mimeview);
}
#endif /*USE_GPGME*/
#endif /* USE_GPGME */

View file

@ -72,7 +72,7 @@ Session *news_session_new(const gchar *server, gushort port)
{
gchar buf[NNTPBUFSIZE];
NNTPSession *session;
gint nntp_sock;
SockInfo *nntp_sock;
g_return_val_if_fail(server != NULL, NULL);
@ -95,7 +95,8 @@ Session *news_session_new(const gchar *server, gushort port)
void news_session_destroy(NNTPSession *session)
{
close(SESSION(session)->sock);
sock_close(SESSION(session)->sock);
SESSION(session)->sock = NULL;
g_free(session->group);
}
@ -584,22 +585,19 @@ GSList * news_get_group_list(FolderItem *item)
if (is_file_exist(filename)) {
debug_print(_("group list has been already cached.\n"));
}
else
{
else {
ok = nntp_list(SESSION(session)->sock);
if (ok != NN_SUCCESS)
return NULL;
if (recv_write_to_file(SESSION(session)->sock, filename)
< 0) {
if (recv_write_to_file(SESSION(session)->sock, filename) < 0) {
log_warning(_("can't retrieve group list\n"));
return NULL;
}
}
}
f = fopen(filename, "r");
while (fgets(buf, NNTPBUFSIZE, f))
{
while (fgets(buf, NNTPBUFSIZE, f)) {
char * s;
len = 0;
@ -609,7 +607,7 @@ GSList * news_get_group_list(FolderItem *item)
s = g_strdup(buf);
group_list = g_slist_append(group_list, s);
}
}
fclose(f);
g_free(filename);

View file

@ -32,31 +32,28 @@
static gint verbose = 1;
static void nntp_gen_send(gint sock, const gchar *format, ...);
static gint nntp_gen_recv(gint sock, gchar *buf, gint size);
static void nntp_gen_send(SockInfo *sock, const gchar *format, ...);
static gint nntp_gen_recv(SockInfo *sock, gchar *buf, gint size);
gint nntp_open(const gchar *server, gushort port, gchar *buf)
SockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
{
SockInfo *sockinfo;
gint sock;
SockInfo *sock;
if ((sockinfo = sock_connect(server, port)) == NULL) {
if ((sock = sock_connect(server, port)) == NULL) {
log_warning(_("Can't connect to NNTP server: %s:%d\n"),
server, port);
return -1;
return NULL;
}
sock = sockinfo->sock;
sock_sockinfo_free(sockinfo);
if (nntp_ok(sock, buf) == NN_SUCCESS)
return sock;
else {
sock_close(sock);
return -1;
return NULL;
}
}
gint nntp_group(gint sock, const gchar *group,
gint nntp_group(SockInfo *sock, const gchar *group,
gint *num, gint *first, gint *last)
{
gint ok;
@ -77,7 +74,7 @@ gint nntp_group(gint sock, const gchar *group,
return NN_SUCCESS;
}
gint nntp_get_article(gint sock, const gchar *cmd, gint num, gchar **msgid)
gint nntp_get_article(SockInfo *sock, const gchar *cmd, gint num, gchar **msgid)
{
gint ok;
gchar buf[NNTPBUFSIZE];
@ -100,27 +97,27 @@ gint nntp_get_article(gint sock, const gchar *cmd, gint num, gchar **msgid)
return NN_SUCCESS;
}
gint nntp_article(gint sock, gint num, gchar **msgid)
gint nntp_article(SockInfo *sock, gint num, gchar **msgid)
{
return nntp_get_article(sock, "ARTICLE", num, msgid);
}
gint nntp_body(gint sock, gint num, gchar **msgid)
gint nntp_body(SockInfo *sock, gint num, gchar **msgid)
{
return nntp_get_article(sock, "BODY", num, msgid);
}
gint nntp_head(gint sock, gint num, gchar **msgid)
gint nntp_head(SockInfo *sock, gint num, gchar **msgid)
{
return nntp_get_article(sock, "HEAD", num, msgid);
}
gint nntp_stat(gint sock, gint num, gchar **msgid)
gint nntp_stat(SockInfo *sock, gint num, gchar **msgid)
{
return nntp_get_article(sock, "STAT", num, msgid);
}
gint nntp_next(gint sock, gint *num, gchar **msgid)
gint nntp_next(SockInfo *sock, gint *num, gchar **msgid)
{
gint ok;
gint resp;
@ -146,7 +143,7 @@ gint nntp_next(gint sock, gint *num, gchar **msgid)
return NN_SUCCESS;
}
gint nntp_xover(gint sock, gint first, gint last)
gint nntp_xover(SockInfo *sock, gint first, gint last)
{
gint ok;
gchar buf[NNTPBUFSIZE];
@ -158,7 +155,7 @@ gint nntp_xover(gint sock, gint first, gint last)
return NN_SUCCESS;
}
gint nntp_post(gint sock, FILE *fp)
gint nntp_post(SockInfo *sock, FILE *fp)
{
gint ok;
gchar buf[NNTPBUFSIZE];
@ -189,17 +186,17 @@ gint nntp_post(gint sock, FILE *fp)
return NN_SUCCESS;
}
gint nntp_newgroups(gint sock)
gint nntp_newgroups(SockInfo *sock)
{
return NN_SUCCESS;
}
gint nntp_newnews(gint sock)
gint nntp_newnews(SockInfo *sock)
{
return NN_SUCCESS;
}
gint nntp_mode(gint sock, gboolean stream)
gint nntp_mode(SockInfo *sock, gboolean stream)
{
gint ok;
@ -209,7 +206,7 @@ gint nntp_mode(gint sock, gboolean stream)
return ok;
}
gint nntp_authinfo_user(gint sock, const gchar *user)
gint nntp_authinfo_user(SockInfo *sock, const gchar *user)
{
gint ok;
gchar buf[NNTPBUFSIZE];
@ -220,7 +217,7 @@ gint nntp_authinfo_user(gint sock, const gchar *user)
return ok;
}
gint nntp_authinfo_pass(gint sock, const gchar *pass)
gint nntp_authinfo_pass(SockInfo *sock, const gchar *pass)
{
gint ok;
gchar buf[NNTPBUFSIZE];
@ -231,7 +228,7 @@ gint nntp_authinfo_pass(gint sock, const gchar *pass)
return ok;
}
gint nntp_ok(gint sock, gchar *argbuf)
gint nntp_ok(SockInfo *sock, gchar *argbuf)
{
gint ok;
gchar buf[NNTPBUFSIZE];
@ -257,7 +254,7 @@ gint nntp_ok(gint sock, gchar *argbuf)
return ok;
}
static void nntp_gen_send(gint sock, const gchar *format, ...)
static void nntp_gen_send(SockInfo *sock, const gchar *format, ...)
{
gchar buf[NNTPBUFSIZE];
va_list args;
@ -277,7 +274,7 @@ static void nntp_gen_send(gint sock, const gchar *format, ...)
sock_write(sock, buf, strlen(buf));
}
static gint nntp_gen_recv(gint sock, gchar *buf, gint size)
static gint nntp_gen_recv(SockInfo *sock, gchar *buf, gint size)
{
if (sock_read(sock, buf, size) == -1)
return NN_SOCKET;
@ -295,7 +292,7 @@ static gint nntp_gen_recv(gint sock, gchar *buf, gint size)
a function is needed to read the newsgroups list.
*/
gint nntp_list(gint sock)
gint nntp_list(SockInfo *sock)
{
GList * result = NULL;

View file

@ -20,6 +20,8 @@
#ifndef __NNTP_H__
#define __NNTP_H__
#include "socket.h"
#define NN_SUCCESS 0
#define NN_SOCKET 2
#define NN_AUTHFAIL 3
@ -28,27 +30,27 @@
#define NN_IOERR 6
#define NN_ERROR 7
#define NN_AUTHREQ 8
#define NN_AUTHCONT 9
#define NN_AUTHCONT 9
#define NNTPBUFSIZE 8192
gint nntp_open(const gchar *server, gushort port, gchar *buf);
gint nntp_group(gint sock, const gchar *group,
SockInfo *nntp_open(const gchar *server, gushort port, gchar *buf);
gint nntp_group(SockInfo *sock, const gchar *group,
gint *num, gint *first, gint *last);
gint nntp_get_article(gint sock, const gchar *cmd, gint num, gchar **msgid);
gint nntp_article(gint sock, gint num, gchar **msgid);
gint nntp_body(gint sock, gint num, gchar **msgid);
gint nntp_head(gint sock, gint num, gchar **msgid);
gint nntp_stat(gint sock, gint num, gchar **msgid);
gint nntp_next(gint sock, gint *num, gchar **msgid);
gint nntp_xover(gint sock, gint first, gint last);
gint nntp_authinfo_user(gint sock, const gchar *user);
gint nntp_authinfo_pass(gint sock, const gchar *pass);
gint nntp_post(gint sock, FILE *fp);
gint nntp_newgroups(gint sock);
gint nntp_newnews(gint sock);
gint nntp_mode(gint sock, gboolean stream);
gint nntp_ok(gint sock, gchar *argbuf);
gint nntp_list(gint sock);
gint nntp_get_article(SockInfo *sock, const gchar *cmd, gint num, gchar **msgid);
gint nntp_article(SockInfo *sock, gint num, gchar **msgid);
gint nntp_body(SockInfo *sock, gint num, gchar **msgid);
gint nntp_head(SockInfo *sock, gint num, gchar **msgid);
gint nntp_stat(SockInfo *sock, gint num, gchar **msgid);
gint nntp_next(SockInfo *sock, gint *num, gchar **msgid);
gint nntp_xover(SockInfo *sock, gint first, gint last);
gint nntp_post(SockInfo *sock, FILE *fp);
gint nntp_newgroups(SockInfo *sock);
gint nntp_newnews(SockInfo *sock);
gint nntp_mode(SockInfo *sock, gboolean stream);
gint nntp_ok(SockInfo *sock, gchar *argbuf);
gint nntp_authinfo_user(SockInfo *sock, const gchar *user);
gint nntp_authinfo_pass(SockInfo *sock, const gchar *pass);
gint nntp_list(SockInfo *sock);
#endif /* __NNTP_H__ */

View file

@ -31,17 +31,17 @@
#include "intl.h"
#include "pop.h"
#include "socket.h"
#include "md5ify.h"
#include "md5.h"
#include "prefs_account.h"
#include "utils.h"
#include "inc.h"
#include "recv.h"
static gint pop3_ok(gint sock, gchar *argbuf);
static void pop3_gen_send(gint sock, const gchar *format, ...);
static gint pop3_gen_recv(gint sock, gchar *buf, gint size);
static gint pop3_ok(SockInfo *sock, gchar *argbuf);
static void pop3_gen_send(SockInfo *sock, const gchar *format, ...);
static gint pop3_gen_recv(SockInfo *sock, gchar *buf, gint size);
gint pop3_greeting_recv(gint sock, gpointer data)
gint pop3_greeting_recv(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
gchar buf[POPBUFSIZE];
@ -56,7 +56,7 @@ gint pop3_greeting_recv(gint sock, gpointer data)
return -1;
}
gint pop3_getauth_user_send(gint sock, gpointer data)
gint pop3_getauth_user_send(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
@ -69,7 +69,7 @@ gint pop3_getauth_user_send(gint sock, gpointer data)
return POP3_GETAUTH_USER_RECV;
}
gint pop3_getauth_user_recv(gint sock, gpointer data)
gint pop3_getauth_user_recv(SockInfo *sock, gpointer data)
{
if (pop3_ok(sock, NULL) == PS_SUCCESS)
return POP3_GETAUTH_PASS_SEND;
@ -77,7 +77,7 @@ gint pop3_getauth_user_recv(gint sock, gpointer data)
return -1;
}
gint pop3_getauth_pass_send(gint sock, gpointer data)
gint pop3_getauth_pass_send(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
@ -88,7 +88,7 @@ gint pop3_getauth_pass_send(gint sock, gpointer data)
return POP3_GETAUTH_PASS_RECV;
}
gint pop3_getauth_pass_recv(gint sock, gpointer data)
gint pop3_getauth_pass_recv(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
@ -101,11 +101,12 @@ gint pop3_getauth_pass_recv(gint sock, gpointer data)
}
}
gint pop3_getauth_apop_send(gint sock, gpointer data)
gint pop3_getauth_apop_send(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
gchar *start, *end;
gchar *apop_str, *md5sum;
gchar *apop_str;
gchar md5sum[33];
g_return_val_if_fail(state->user != NULL, -1);
g_return_val_if_fail(state->pass != NULL, -1);
@ -126,7 +127,7 @@ gint pop3_getauth_apop_send(gint sock, gpointer data)
*(end + 1) = '\0';
apop_str = g_strconcat(start, state->pass, NULL);
md5sum = MD5Digest(apop_str);
md5_hex_digest(md5sum, apop_str);
g_free(apop_str);
pop3_gen_send(sock, "APOP %s %s", state->user, md5sum);
@ -134,7 +135,7 @@ gint pop3_getauth_apop_send(gint sock, gpointer data)
return POP3_GETAUTH_APOP_RECV;
}
gint pop3_getauth_apop_recv(gint sock, gpointer data)
gint pop3_getauth_apop_recv(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
@ -147,7 +148,7 @@ gint pop3_getauth_apop_recv(gint sock, gpointer data)
}
}
gint pop3_getrange_stat_send(gint sock, gpointer data)
gint pop3_getrange_stat_send(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
@ -158,7 +159,7 @@ gint pop3_getrange_stat_send(gint sock, gpointer data)
return POP3_GETRANGE_STAT_RECV;
}
gint pop3_getrange_stat_recv(gint sock, gpointer data)
gint pop3_getrange_stat_recv(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
gchar buf[POPBUFSIZE + 1];
@ -187,14 +188,14 @@ gint pop3_getrange_stat_recv(gint sock, gpointer data)
return -1;
}
gint pop3_getrange_last_send(gint sock, gpointer data)
gint pop3_getrange_last_send(SockInfo *sock, gpointer data)
{
pop3_gen_send(sock, "LAST");
return POP3_GETRANGE_LAST_RECV;
}
gint pop3_getrange_last_recv(gint sock, gpointer data)
gint pop3_getrange_last_recv(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
gchar buf[POPBUFSIZE + 1];
@ -218,14 +219,14 @@ gint pop3_getrange_last_recv(gint sock, gpointer data)
return POP3_RETR_SEND;
}
gint pop3_getrange_uidl_send(gint sock, gpointer data)
gint pop3_getrange_uidl_send(SockInfo *sock, gpointer data)
{
pop3_gen_send(sock, "UIDL");
return POP3_GETRANGE_UIDL_RECV;
}
gint pop3_getrange_uidl_recv(gint sock, gpointer data)
gint pop3_getrange_uidl_recv(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
gboolean nb;
@ -270,7 +271,7 @@ gint pop3_getrange_uidl_recv(gint sock, gpointer data)
return POP3_LOGOUT_SEND;
}
gint pop3_retr_send(gint sock, gpointer data)
gint pop3_retr_send(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
@ -281,7 +282,7 @@ gint pop3_retr_send(gint sock, gpointer data)
return POP3_RETR_RECV;
}
gint pop3_retr_recv(gint sock, gpointer data)
gint pop3_retr_recv(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
const gchar *file;
@ -318,7 +319,7 @@ gint pop3_retr_recv(gint sock, gpointer data)
return -1;
}
gint pop3_delete_send(gint sock, gpointer data)
gint pop3_delete_send(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
@ -329,7 +330,7 @@ gint pop3_delete_send(gint sock, gpointer data)
return POP3_DELETE_RECV;
}
gint pop3_delete_recv(gint sock, gpointer data)
gint pop3_delete_recv(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
gint ok;
@ -346,7 +347,7 @@ gint pop3_delete_recv(gint sock, gpointer data)
return -1;
}
gint pop3_logout_send(gint sock, gpointer data)
gint pop3_logout_send(SockInfo *sock, gpointer data)
{
Pop3State *state = (Pop3State *)data;
@ -357,7 +358,7 @@ gint pop3_logout_send(gint sock, gpointer data)
return POP3_LOGOUT_RECV;
}
gint pop3_logout_recv(gint sock, gpointer data)
gint pop3_logout_recv(SockInfo *sock, gpointer data)
{
if (pop3_ok(sock, NULL) == PS_SUCCESS)
return -1;
@ -365,7 +366,7 @@ gint pop3_logout_recv(gint sock, gpointer data)
return -1;
}
static gint pop3_ok(gint sock, gchar *argbuf)
static gint pop3_ok(SockInfo *sock, gchar *argbuf)
{
gint ok;
gchar buf[POPBUFSIZE + 1];
@ -407,7 +408,7 @@ static gint pop3_ok(gint sock, gchar *argbuf)
return ok;
}
static void pop3_gen_send(gint sock, const gchar *format, ...)
static void pop3_gen_send(SockInfo *sock, const gchar *format, ...)
{
gchar buf[POPBUFSIZE + 1];
va_list args;
@ -425,7 +426,7 @@ static void pop3_gen_send(gint sock, const gchar *format, ...)
sock_write(sock, buf, strlen(buf));
}
static gint pop3_gen_recv(gint sock, gchar *buf, gint size)
static gint pop3_gen_recv(SockInfo *sock, gchar *buf, gint size)
{
gboolean nb;

View file

@ -22,6 +22,8 @@
#include <glib.h>
#include "socket.h"
typedef enum {
POP3_GREETING_RECV,
POP3_GETAUTH_USER_SEND,
@ -71,24 +73,24 @@ typedef enum {
#define PS_RETAINED 26 /* message retained (internal use) */
#define PS_TRUNCATED 27 /* headers incomplete (internal use) */
gint pop3_greeting_recv (gint sock, gpointer data);
gint pop3_getauth_user_send (gint sock, gpointer data);
gint pop3_getauth_user_recv (gint sock, gpointer data);
gint pop3_getauth_pass_send (gint sock, gpointer data);
gint pop3_getauth_pass_recv (gint sock, gpointer data);
gint pop3_getauth_apop_send (gint sock, gpointer data);
gint pop3_getauth_apop_recv (gint sock, gpointer data);
gint pop3_getrange_stat_send (gint sock, gpointer data);
gint pop3_getrange_stat_recv (gint sock, gpointer data);
gint pop3_getrange_last_send (gint sock, gpointer data);
gint pop3_getrange_last_recv (gint sock, gpointer data);
gint pop3_getrange_uidl_send (gint sock, gpointer data);
gint pop3_getrange_uidl_recv (gint sock, gpointer data);
gint pop3_retr_send (gint sock, gpointer data);
gint pop3_retr_recv (gint sock, gpointer data);
gint pop3_delete_send (gint sock, gpointer data);
gint pop3_delete_recv (gint sock, gpointer data);
gint pop3_logout_send (gint sock, gpointer data);
gint pop3_logout_recv (gint sock, gpointer data);
gint pop3_greeting_recv (SockInfo *sock, gpointer data);
gint pop3_getauth_user_send (SockInfo *sock, gpointer data);
gint pop3_getauth_user_recv (SockInfo *sock, gpointer data);
gint pop3_getauth_pass_send (SockInfo *sock, gpointer data);
gint pop3_getauth_pass_recv (SockInfo *sock, gpointer data);
gint pop3_getauth_apop_send (SockInfo *sock, gpointer data);
gint pop3_getauth_apop_recv (SockInfo *sock, gpointer data);
gint pop3_getrange_stat_send (SockInfo *sock, gpointer data);
gint pop3_getrange_stat_recv (SockInfo *sock, gpointer data);
gint pop3_getrange_last_send (SockInfo *sock, gpointer data);
gint pop3_getrange_last_recv (SockInfo *sock, gpointer data);
gint pop3_getrange_uidl_send (SockInfo *sock, gpointer data);
gint pop3_getrange_uidl_recv (SockInfo *sock, gpointer data);
gint pop3_retr_send (SockInfo *sock, gpointer data);
gint pop3_retr_recv (SockInfo *sock, gpointer data);
gint pop3_delete_send (SockInfo *sock, gpointer data);
gint pop3_delete_recv (SockInfo *sock, gpointer data);
gint pop3_logout_send (SockInfo *sock, gpointer data);
gint pop3_logout_recv (SockInfo *sock, gpointer data);
#endif /* __POP_H__ */

View file

@ -368,7 +368,7 @@ void prefs_set_default(PrefParam *param)
g_strdup(g_getenv(param[i].defval + 4));
else if (param[i].defval[0] == '~')
*((gchar **)param[i].data) =
g_strconcat(g_get_home_dir(),
g_strconcat(get_home_dir(),
param[i].defval + 1,
NULL);
else if (param[i].defval[0] != '\0')
@ -530,7 +530,7 @@ void prefs_set_dialog_to_default(PrefParam *param)
break;
} else if (tmpparam.defval[0] == '~') {
str_data =
g_strconcat(g_get_home_dir(),
g_strconcat(get_home_dir(),
param[i].defval + 1,
NULL);
tmpparam.data = &str_data;

View file

@ -823,7 +823,7 @@ static void prefs_account_send_create(void)
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
// gtk_widget_set_sensitive(hbox, FALSE);
/* gtk_widget_set_sensitive(hbox, FALSE); */
PACK_CHECK_BUTTON (hbox, customhdr_chkbtn,
_("Add user-defined header"));

View file

@ -20,6 +20,10 @@
#ifndef __PREFS_ACCOUNT_H__
#define __PREFS_ACCOUNT_H__
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <glib.h>
typedef struct _PrefsAccount PrefsAccount;

View file

@ -102,6 +102,7 @@ static struct Display {
GtkWidget *chkbtn_folder_unread;
GtkWidget *chkbtn_transhdr;
GtkWidget *chkbtn_swapfrom;
GtkWidget *chkbtn_hscrollbar;
GtkWidget *entry_datefmt;
@ -274,10 +275,11 @@ static PrefParam param[] = {
&display.chkbtn_folder_unread,
prefs_set_data_from_toggle, prefs_set_toggle},
/* Display: Summary View */
{"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL,
&display.chkbtn_transhdr,
prefs_set_data_from_toggle, prefs_set_toggle},
/* Display: Summary View */
{"enable_swap_from", "TRUE", &prefs_common.swap_from, P_BOOL,
&display.chkbtn_swapfrom,
prefs_set_data_from_toggle, prefs_set_toggle},
@ -433,9 +435,11 @@ static PrefParam param[] = {
&prefs_common.auto_check_signatures, P_BOOL,
&privacy.checkbtn_auto_check_signatures,
prefs_set_data_from_toggle, prefs_set_toggle},
#ifndef __MINGW32__
{"passphrase_grab", "FALSE", &prefs_common.passphrase_grab, P_BOOL,
&privacy.checkbtn_passphrase_grab,
prefs_set_data_from_toggle, prefs_set_toggle},
#endif /* __MINGW32__ */
{"default_signkey", CS_AUTO, &prefs_common.default_signkey, P_STRING,
&privacy.optmenu_default_signkey,
prefs_common_default_signkey_set_data_from_optmenu,
@ -1150,6 +1154,10 @@ static void prefs_display_create(void)
PACK_CHECK_BUTTON
(vbox2, chkbtn_hscrollbar, _("Enable horizontal scroll bar"));
hbox1 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox1);
gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
label_datefmt = gtk_label_new (_("Date format"));
gtk_widget_show (label_datefmt);
gtk_box_pack_start (GTK_BOX (hbox1), label_datefmt, FALSE, FALSE, 0);
@ -1201,8 +1209,8 @@ static void prefs_display_create(void)
display.button_textfont = button_textfont;
display.chkbtn_folder_unread = chkbtn_folder_unread;
display.chkbtn_transhdr = chkbtn_transhdr;
display.chkbtn_swapfrom = chkbtn_swapfrom;
display.chkbtn_hscrollbar = chkbtn_hscrollbar;
display.entry_datefmt = entry_datefmt;
@ -1383,8 +1391,10 @@ static void prefs_privacy_create(void)
PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
_("Automatically check signatures"));
#ifndef __MINGW32__
PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
_("Grab input while entering a passphrase"));
#endif
hbox1 = gtk_hbox_new (FALSE, 8);
gtk_widget_show (hbox1);
@ -1546,7 +1556,7 @@ static void prefs_interface_create(void)
SET_TOGGLE_SENSITIVITY (checkbtn_cleanonexit, checkbtn_askonclean);
PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued,
_("Warn if there are queued messages on exit"));
_("Warn if there are queued messages"));
interface.checkbtn_emacs = checkbtn_emacs;
interface.checkbtn_openunread = checkbtn_openunread;
@ -1666,6 +1676,7 @@ void prefs_quote_colors_dialog(void)
gtk_widget_hide(quote_color_win);
textview_update_message_colors();
main_window_reflect_prefs_all();
}
static void prefs_quote_colors_dialog_create(void)

View file

@ -20,6 +20,10 @@
#ifndef __PREFS_COMMON_H__
#define __PREFS_COMMON_H__
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <glib.h>
#include "mainwindow.h"

View file

@ -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

View file

@ -44,6 +44,11 @@ ProgressDialog *progress_dialog_create(void)
GtkWidget *cancel_btn;
GtkWidget *cancel_area;
GtkWidget *progressbar;
GtkWidget *clist;
gchar *text[] = {NULL, NULL, NULL};
text[1] = _("Account");
text[2] = _("Status");
debug_print(_("Creating progress dialog...\n"));
progress = g_new0(ProgressDialog, 1);
@ -74,13 +79,23 @@ ProgressDialog *progress_dialog_create(void)
gtk_widget_show_all(cancel_area);
progressbar = gtk_progress_bar_new();
gtk_box_pack_end(GTK_BOX(vbox), progressbar, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), progressbar, FALSE, FALSE, 0);
gtk_widget_show(progressbar);
clist = gtk_clist_new_with_titles(3, text);
gtk_widget_show(clist);
gtk_box_pack_start(GTK_BOX(vbox), clist, TRUE, TRUE, 0);
gtk_widget_set_usize(clist, -1, 120);
gtk_clist_set_column_justification(GTK_CLIST(clist), 0,
GTK_JUSTIFY_CENTER);
gtk_clist_set_column_width(GTK_CLIST(clist), 0, 16);
gtk_clist_set_column_width(GTK_CLIST(clist), 1, 100);
progress->window = window;
progress->label = label;
progress->cancel_btn = cancel_btn;
progress->progressbar = progressbar;
progress->clist = clist;
return progress;
}

View file

@ -20,6 +20,7 @@
#ifndef __PROGRESS_H__
#define __PROGRESS_H__
#include <glib.h>
#include <gtk/gtkwidget.h>
typedef struct _ProgressDialog ProgressDialog;
@ -30,6 +31,7 @@ struct _ProgressDialog
GtkWidget *label;
GtkWidget *cancel_btn;
GtkWidget *progressbar;
GtkWidget *clist;
};
ProgressDialog *progress_dialog_create (void);

View file

@ -33,7 +33,7 @@
#define BUFFSIZE 8192
gint recv_write_to_file(gint sock, const gchar *filename)
gint recv_write_to_file(SockInfo *sock, const gchar *filename)
{
FILE *fp;
@ -63,7 +63,7 @@ gint recv_write_to_file(gint sock, const gchar *filename)
return 0;
}
gint recv_bytes_write_to_file(gint sock, glong size, const gchar *filename)
gint recv_bytes_write_to_file(SockInfo *sock, glong size, const gchar *filename)
{
FILE *fp;
@ -93,7 +93,7 @@ gint recv_bytes_write_to_file(gint sock, glong size, const gchar *filename)
return 0;
}
gint recv_write(gint sock, FILE *fp)
gint recv_write(SockInfo *sock, FILE *fp)
{
gchar buf[BUFFSIZE];
gint len;
@ -137,7 +137,7 @@ gint recv_write(gint sock, FILE *fp)
return 0;
}
gint recv_bytes_write(gint sock, glong size, FILE *fp)
gint recv_bytes_write(SockInfo *sock, glong size, FILE *fp)
{
gchar *buf;
gboolean nb;
@ -152,7 +152,8 @@ gint recv_bytes_write(gint sock, glong size, FILE *fp)
do {
size_t read_count;
read_count = read(sock, buf + count, size - count);
/* FIXME: put this into socket.c :WK: */
read_count = fd_read(sock->sock, buf + count, size - count);
if (read_count < 0) {
if (nb) sock_set_nonblocking_mode(sock, TRUE);
return -1;

View file

@ -22,9 +22,11 @@
#include <glib.h>
gint recv_write_to_file(gint sock, const gchar *filename);
gint recv_bytes_write_to_file(gint sock, glong size, const gchar *filename);
gint recv_write(gint sock, FILE *fp);
gint recv_bytes_write(gint sock, glong size, FILE *fp);
#include "socket.h"
gint recv_write_to_file(SockInfo *sock, const gchar *filename);
gint recv_bytes_write_to_file(SockInfo *sock, glong size, const gchar *filename);
gint recv_write(SockInfo *sock, FILE *fp);
gint recv_bytes_write(SockInfo *sock, glong size, FILE *fp);
#endif /* __RECV_H__ */

View file

@ -43,6 +43,7 @@
#include "prefs_common.h"
#include "passphrase.h"
#include "select-keys.h"
#include "sigstatus.h"
#include "rfc2015.h"
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
@ -278,8 +279,11 @@ static void check_signature (MimeInfo *mimeinfo, MimeInfo *partinfo, FILE *fp)
GpgmeError err;
GpgmeData sig = NULL, text = NULL;
GpgmeSigStat status = GPGME_SIG_STAT_NONE;
GpgmegtkSigStatus statuswindow;
const char *result = NULL;
statuswindow = gpgmegtk_sig_status_create ();
err = gpgme_new (&ctx);
if (err) {
g_warning ("gpgme_new failed: %s", gpgme_strerror (err));
@ -305,20 +309,24 @@ static void check_signature (MimeInfo *mimeinfo, MimeInfo *partinfo, FILE *fp)
if (err)
g_message ("gpgme_op_verify failed: %s", gpgme_strerror (err));
/* FIXME: check what the heck this sig_status_full stuff is.
* it should better go into sigstatus.c */
g_free (partinfo->sigstatus_full);
partinfo->sigstatus_full = sig_status_full (ctx);
leave:
result = sig_status_to_string(status);
result = gpgmegtk_sig_status_to_string(status);
debug_print("verification status: %s\n", result);
gpgmegtk_sig_status_update(statuswindow,ctx);
g_assert (!err);
g_assert (!err); /* FIXME: Hey: this may indeed happen */
g_free (partinfo->sigstatus);
partinfo->sigstatus = g_strdup (result);
gpgme_data_release (sig);
gpgme_data_release (text);
gpgme_release (ctx);
gpgmegtk_sig_status_destroy(statuswindow);
}
static const char *
@ -867,7 +875,7 @@ failure:
return -1; /* error */
}
static int
int
set_signers (GpgmeCtx ctx, PrefsAccount *ac)
{
GSList *key_list = NULL;

View file

@ -74,8 +74,8 @@ struct select_keys_s {
};
static void set_row (GtkCList *clist, GpgmeKey key );
static void fill_clist (struct select_keys_s *sk, const char *pattern );
static void set_row (GtkCList *clist, GpgmeKey key);
static void fill_clist (struct select_keys_s *sk, const char *pattern);
static void create_dialog (struct select_keys_s *sk);
static void open_dialog (struct select_keys_s *sk);
static void close_dialog (struct select_keys_s *sk);
@ -84,7 +84,7 @@ static void key_pressed_cb (GtkWidget *widget,
static void select_btn_cb (GtkWidget *widget, gpointer data);
static void cancel_btn_cb (GtkWidget *widget, gpointer data);
static void other_btn_cb (GtkWidget *widget, gpointer data);
static void sort_keys ( struct select_keys_s *sk, enum col_titles column);
static void sort_keys (struct select_keys_s *sk, enum col_titles column);
static void sort_keys_name (GtkWidget *widget, gpointer data);
static void sort_keys_email (GtkWidget *widget, gpointer data);
@ -101,8 +101,8 @@ update_progress (struct select_keys_s *sk, int running, const char *pattern)
else
buf = g_strdup_printf (_("Collecting info for `%s' ... %c"),
pattern,
windmill[running%DIM(windmill)] );
gtk_label_set_text (sk->toplabel, buf );
windmill[running%DIM(windmill)]);
gtk_label_set_text (sk->toplabel, buf);
g_free (buf);
}
@ -128,7 +128,7 @@ gpgmegtk_recipient_selection (GSList *recp_names)
err = gpgme_recipients_new (&sk.rset);
if (err) {
g_message ("** failed to allocate recipients set: %s",
gpgme_strerror (err) );
gpgme_strerror (err));
return NULL;
}
@ -142,7 +142,7 @@ gpgmegtk_recipient_selection (GSList *recp_names)
gtk_main ();
if (recp_names)
recp_names = recp_names->next;
} while (sk.okay && recp_names );
} while (sk.okay && recp_names);
close_dialog (&sk);
@ -161,30 +161,35 @@ destroy_key (gpointer data)
}
static void
set_row (GtkCList *clist, GpgmeKey key )
set_row (GtkCList *clist, GpgmeKey key)
{
const char *s;
const char *text[N_COL_TITLES];
char *algo_buf;
int row;
/* first check whether the key is capable of encryption which is not
* the case for revoked, expired or sign-only keys */
if ( !gpgme_key_get_ulong_attr (key, GPGME_ATTR_CAN_ENCRYPT, NULL, 0 ) )
return;
algo_buf = g_strdup_printf ("%lu/%s",
gpgme_key_get_ulong_attr (key, GPGME_ATTR_LEN, NULL, 0 ),
gpgme_key_get_string_attr (key, GPGME_ATTR_ALGO, NULL, 0 ) );
text[COL_ALGO] = algo_buf;
s = gpgme_key_get_string_attr (key, GPGME_ATTR_KEYID, NULL, 0 );
if ( strlen (s) == 16 )
s = gpgme_key_get_string_attr (key, GPGME_ATTR_KEYID, NULL, 0);
if (strlen (s) == 16)
s += 8; /* show only the short keyID */
text[COL_KEYID] = s;
s = gpgme_key_get_string_attr (key, GPGME_ATTR_NAME, NULL, 0 );
s = gpgme_key_get_string_attr (key, GPGME_ATTR_NAME, NULL, 0);
text[COL_NAME] = s;
s = gpgme_key_get_string_attr (key, GPGME_ATTR_EMAIL, NULL, 0 );
s = gpgme_key_get_string_attr (key, GPGME_ATTR_EMAIL, NULL, 0);
text[COL_EMAIL] = s;
s = gpgme_key_get_string_attr (key, GPGME_ATTR_VALIDITY, NULL, 0 );
s = gpgme_key_get_string_attr (key, GPGME_ATTR_VALIDITY, NULL, 0);
text[COL_VALIDITY] = s;
row = gtk_clist_append (clist, (gchar**)text);
@ -195,7 +200,7 @@ set_row (GtkCList *clist, GpgmeKey key )
static void
fill_clist (struct select_keys_s *sk, const char *pattern )
fill_clist (struct select_keys_s *sk, const char *pattern)
{
GtkCList *clist;
GpgmeCtx ctx;
@ -207,15 +212,11 @@ fill_clist (struct select_keys_s *sk, const char *pattern )
clist = sk->clist;
g_return_if_fail (clist);
debug_print ("select_keys:fill_clist: pattern `%s'\n", pattern );
debug_print ("select_keys:fill_clist: pattern `%s'\n", pattern);
/*gtk_clist_freeze (select_keys.clist);*/
err = gpgme_new (&ctx);
if (err) {
g_message ("** gpgme_new failed: %s",
gpgme_strerror (err));
return;
}
g_assert (!err);
sk->select_ctx = ctx;
@ -223,12 +224,11 @@ fill_clist (struct select_keys_s *sk, const char *pattern )
while (gtk_events_pending ())
gtk_main_iteration ();
err = gpgme_op_keylist_start (ctx, pattern, 0 );
err = gpgme_op_keylist_start (ctx, pattern, 0);
if (err) {
g_message ("** gpgme_op_keylist_start(%s) failed: %s",
pattern, gpgme_strerror (err));
sk->select_ctx = NULL;
gpgme_release (ctx);
return;
}
update_progress (sk, ++running, pattern);
@ -240,7 +240,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern )
gtk_main_iteration ();
}
debug_print ("%% %s:%d: ready\n", __FILE__ ,__LINE__ );
if ( err != GPGME_EOF )
if (err != GPGME_EOF)
g_message ("** gpgme_op_keylist_next failed: %s",
gpgme_strerror (err));
sk->select_ctx = NULL;
@ -499,13 +499,13 @@ sort_keys ( struct select_keys_s *sk, enum col_titles column)
static void
sort_keys_name (GtkWidget *widget, gpointer data)
{
sort_keys ( (struct select_keys_s*)data, COL_NAME );
sort_keys ((struct select_keys_s*)data, COL_NAME);
}
static void
sort_keys_email (GtkWidget *widget, gpointer data)
{
sort_keys ( (struct select_keys_s*)data, COL_EMAIL );
sort_keys ((struct select_keys_s*)data, COL_EMAIL);
}

View file

@ -45,14 +45,15 @@ static gint send_message_smtp (GSList *to_list, const gchar *from,
const gchar *domain, const gchar *userid,
const gchar *passwd, gboolean use_smtp_auth,
FILE *fp);
static gint send_smtp_open (const gchar *server, gushort port,
static SockInfo *send_smtp_open (const gchar *server, gushort port,
const gchar *domain, gboolean use_smtp_auth);
#define SEND_EXIT_IF_ERROR(f, s) \
{ \
if ((f) < 0) { \
if (!(f)) { \
log_warning("Error occurred while %s\n", s); \
if (smtp_sock > 0) sock_close(smtp_sock); \
sock_close(smtp_sock); \
smtp_sock = NULL; \
return -1; \
} \
}
@ -64,6 +65,7 @@ static gint send_smtp_open (const gchar *server, gushort port,
if (smtp_quit(smtp_sock) != SM_OK) \
log_warning("Error occurred while sending QUIT\n"); \
sock_close(smtp_sock); \
smtp_sock = NULL; \
return -1; \
} \
}
@ -185,7 +187,7 @@ static gint send_message_smtp(GSList *to_list, const gchar *from,
const gchar* passwd, gboolean use_smtp_auth,
FILE *fp)
{
gint smtp_sock;
SockInfo *smtp_sock;
gchar buf[BUFFSIZE];
GSList *cur;
@ -226,22 +228,19 @@ static gint send_message_smtp(GSList *to_list, const gchar *from,
return 0;
}
static gint send_smtp_open(const gchar *server, gushort port,
static SockInfo *send_smtp_open(const gchar *server, gushort port,
const gchar *domain, gboolean use_smtp_auth)
{
SockInfo *sockinfo;
gint sock;
SockInfo *sock;
gint val;
g_return_val_if_fail(server != NULL, -1);
g_return_val_if_fail(server != NULL, NULL);
if ((sockinfo = sock_connect(server, port)) == NULL) {
if ((sock = sock_connect(server, port)) == NULL) {
log_warning(_("Can't connect to SMTP server: %s:%d\n"),
server, port);
return -1;
return NULL;
}
sock = sockinfo->sock;
sock_sockinfo_free(sockinfo);
if (smtp_ok(sock) == SM_OK) {
val = smtp_helo(sock, domain ? domain : get_domain_name(),
@ -252,5 +251,5 @@ static gint send_smtp_open(const gchar *server, gushort port,
log_warning(_("Error occurred while sending HELO\n"));
sock_close(sock);
return -1;
return NULL;
}

View file

@ -21,6 +21,7 @@
#define __SESSION_H__
#include <glib.h>
#include "socket.h"
typedef struct _Session Session;
@ -41,7 +42,7 @@ struct _Session
{
SessionType type;
gint sock;
SockInfo *sock;
gchar *server;
gboolean connected;

236
src/sigstatus.c Normal file
View file

@ -0,0 +1,236 @@
/* sigstatus.h - GTK+ based signature status display
* Copyright (C) 2001 Werner Koch (dd9jn)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#if USE_GPGME
#include <glib.h>
#include <gtk/gtkwindow.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkbutton.h>
#include <gdk/gdkkeysyms.h>
#include <gpgme.h>
#include "intl.h"
#include "gtkutils.h"
#include "utils.h"
#include "sigstatus.h"
/* remove the window after 30 seconds to avoid cluttering the deskop
* with too many of them */
#define MY_TIMEOUT (30*1000)
struct gpgmegtk_sig_status_s {
GtkWidget *mainwindow;
GtkWidget *label;
int running;
int destroy_pending;
guint timeout_id;
int timeout_id_valid;
};
static void do_destroy(GpgmegtkSigStatus hd)
{
if (!hd->running ) {
if (hd->mainwindow) {
gtk_widget_destroy ( hd->mainwindow );
hd->mainwindow = NULL;
}
if (hd->timeout_id_valid) {
gtk_timeout_remove(hd->timeout_id);
hd->timeout_id_valid = 0;
}
if(hd->destroy_pending)
g_free(hd);
}
}
static void okay_cb(GtkWidget *widget, gpointer data)
{
GpgmegtkSigStatus hd = data;
hd->running = 0;
do_destroy(hd);
}
static void key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
GpgmegtkSigStatus hd = data;
if (event && event->keyval == GDK_Escape) {
hd->running = 0;
do_destroy(hd);
}
}
GpgmegtkSigStatus gpgmegtk_sig_status_create()
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *okay_btn;
GtkWidget *okay_area;
GpgmegtkSigStatus hd;
hd = g_malloc0(sizeof *hd);
hd->running = 1;
window = gtk_window_new(GTK_WINDOW_DIALOG);
hd->mainwindow = window;
gtk_widget_set_usize(window, 400, -1);
gtk_container_set_border_width(GTK_CONTAINER(window), 8);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(okay_cb), hd);
gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
GTK_SIGNAL_FUNC(key_pressed), hd);
vbox = gtk_vbox_new(FALSE, 8);
gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 8);
gtk_widget_show(hbox);
label = gtk_label_new(_("Checking signature"));
hd->label = label;
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 8);
gtk_widget_show(label);
gtkut_button_set_create(&okay_area, &okay_btn, _("Okay"),
NULL, NULL, NULL, NULL);
gtk_box_pack_end(GTK_BOX(vbox), okay_area, FALSE, FALSE, 0);
gtk_widget_grab_default(okay_btn);
gtk_signal_connect(GTK_OBJECT(okay_btn), "clicked",
GTK_SIGNAL_FUNC(okay_cb), hd);
gtk_widget_show_all(window);
while (gtk_events_pending())
gtk_main_iteration();
return hd;
}
static gint timeout_cb(gpointer data)
{
GpgmegtkSigStatus hd = data;
hd->running = 0;
hd->timeout_id_valid = 0;
do_destroy(hd);
return FALSE;
}
void gpgmegtk_sig_status_destroy(GpgmegtkSigStatus hd)
{
if( hd ) {
hd->destroy_pending = 1;
if (hd->running && !hd->timeout_id_valid) {
hd->timeout_id = gtk_timeout_add(MY_TIMEOUT,
timeout_cb, hd);
hd->timeout_id_valid = 1;
}
do_destroy(hd);
}
}
/* Fixme: remove status and get it from the context */
void gpgmegtk_sig_status_update(GpgmegtkSigStatus hd, GpgmeCtx ctx)
{
int idx;
time_t created;
GpgmeSigStat status;
char *text = NULL;
if (!hd || !hd->running || !ctx)
return;
for (idx=0; gpgme_get_sig_status(ctx, idx, &status, &created); idx++ ) {
char *tmp;
const char *userid;
GpgmeKey key = NULL;
if ( !gpgme_get_sig_key (ctx, idx, &key) ) {
userid = gpgme_key_get_string_attr (key, GPGME_ATTR_USERID,
NULL, 0);
}
else
userid = "[?]";
tmp = g_strdup_printf ( "%s%s%s from \"%s\"",
text? text:"",
text? "\n":"",
gpgmegtk_sig_status_to_string(status),
userid );
g_free (text);
text = tmp;
gpgme_key_unref (key);
}
gtk_label_set_text(GTK_LABEL(hd->label), text );
g_free (text);
while (gtk_events_pending())
gtk_main_iteration();
}
const char *gpgmegtk_sig_status_to_string(GpgmeSigStat status)
{
const char *result = "?";
switch ( status ) {
case GPGME_SIG_STAT_NONE:
result = _("Oops: Signature not verified");
break;
case GPGME_SIG_STAT_NOSIG:
result = _("No signature found");
break;
case GPGME_SIG_STAT_GOOD:
result = _("Good signature");
break;
case GPGME_SIG_STAT_BAD:
result = _("BAD signature");
break;
case GPGME_SIG_STAT_NOKEY:
result = _("No public key to verify the signature");
break;
case GPGME_SIG_STAT_ERROR:
result = _("Error verifying the signature");
break;
}
return result;
}
#endif /* USE_GPGME */

33
src/sigstatus.h Normal file
View file

@ -0,0 +1,33 @@
/* sigstatus.h - GTK+ based signature status display
* Copyright (C) 2001 Werner Koch (dd9jn)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef GPGMEGTK_SIGSTATUS_H
#define GPGMEGTK_SIGSTATUS_H
#include <gpgme.h>
struct gpgmegtk_sig_status_s;
typedef struct gpgmegtk_sig_status_s *GpgmegtkSigStatus;
GpgmegtkSigStatus gpgmegtk_sig_status_create(void);
void gpgmegtk_sig_status_destroy(GpgmegtkSigStatus hd);
void gpgmegtk_sig_status_update(GpgmegtkSigStatus hd, GpgmeCtx ctx);
const char *gpgmegtk_sig_status_to_string(GpgmeSigStat status);
#endif /* GPGMEGTK_SIGSTATUS_H */

386
src/simple-gettext.c Normal file
View file

@ -0,0 +1,386 @@
/* simple-gettext.c - a simplified version of gettext.
* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/* This is a simplified version of gettext written by Ulrich Drepper.
* It is used for the Win32 version of GnuPG becuase all the overhead
* of gettext is not needed and we have to do some special Win32 stuff.
* I decided that this is far easier than to tweak gettext for the special
* cases (I tried it but it is a lot of code). wk 15.09.99
*/
#include <config.h>
#ifdef USE_SIMPLE_GETTEXT
#ifndef __MINGW32__
#error This file can only be used with MinGW32
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <windows.h>
#include "w32reg.h"
typedef unsigned int u32; /* That is fine with MingW32 */
typedef unsigned long ulong;
/* The magic number of the GNU message catalog format. */
#define MAGIC 0x950412de
#define MAGIC_SWAPPED 0xde120495
/* Revision number of the currently used .mo (binary) file format. */
#define MO_REVISION_NUMBER 0
/* Header for binary .mo file format. */
struct mo_file_header
{
/* The magic number. */
u32 magic;
/* The revision number of the file format. */
u32 revision;
/* The number of strings pairs. */
u32 nstrings;
/* Offset of table with start offsets of original strings. */
u32 orig_tab_offset;
/* Offset of table with start offsets of translation strings. */
u32 trans_tab_offset;
/* Size of hashing table. */
u32 hash_tab_size;
/* Offset of first hashing entry. */
u32 hash_tab_offset;
};
struct string_desc
{
/* Length of addressed string. */
u32 length;
/* Offset of string in file. */
u32 offset;
};
struct loaded_domain
{
char *data;
int must_swap;
u32 nstrings;
char *mapped;
struct string_desc *orig_tab;
struct string_desc *trans_tab;
u32 hash_size;
u32 *hash_tab;
};
static struct loaded_domain *the_domain;
static __inline__ u32
do_swap_u32( u32 i )
{
return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
}
#define SWAPIT(flag, data) ((flag) ? do_swap_u32(data) : (data) )
/* We assume to have `unsigned long int' value with at least 32 bits. */
#define HASHWORDBITS 32
/* The so called `hashpjw' function by P.J. Weinberger
[see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
1986, 1987 Bell Telephone Laboratories, Inc.] */
static __inline__ ulong
hash_string( const char *str_param )
{
unsigned long int hval, g;
const char *str = str_param;
hval = 0;
while (*str != '\0')
{
hval <<= 4;
hval += (unsigned long int) *str++;
g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
if (g != 0)
{
hval ^= g >> (HASHWORDBITS - 8);
hval ^= g;
}
}
return hval;
}
static struct loaded_domain *
load_domain( const char *filename )
{
FILE *fp;
size_t size;
struct stat st;
struct mo_file_header *data = NULL;
struct loaded_domain *domain = NULL;
size_t to_read;
char *read_ptr;
fp = fopen( filename, "rb" );
if( !fp )
return NULL; /* can't open the file */
/* we must know about the size of the file */
if( fstat( fileno(fp ), &st )
|| (size = (size_t)st.st_size) != st.st_size
|| size < sizeof (struct mo_file_header) ) {
fclose( fp );
return NULL;
}
data = malloc( size );
if( !data ) {
fclose( fp );
return NULL; /* out of memory */
}
to_read = size;
read_ptr = (char *) data;
do {
long int nb = fread( read_ptr, 1, to_read, fp );
if( nb < to_read ) {
fclose (fp);
free(data);
return NULL; /* read error */
}
read_ptr += nb;
to_read -= nb;
} while( to_read > 0 );
fclose (fp);
/* Using the magic number we can test whether it really is a message
* catalog file. */
if( data->magic != MAGIC && data->magic != MAGIC_SWAPPED ) {
/* The magic number is wrong: not a message catalog file. */
free( data );
return NULL;
}
domain = calloc( 1, sizeof *domain );
if( !domain ) {
free( data );
return NULL;
}
domain->data = (char *) data;
domain->must_swap = data->magic != MAGIC;
/* Fill in the information about the available tables. */
switch( SWAPIT(domain->must_swap, data->revision) ) {
case 0:
domain->nstrings = SWAPIT(domain->must_swap, data->nstrings);
domain->orig_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->orig_tab_offset));
domain->trans_tab = (struct string_desc *)
((char *) data + SWAPIT(domain->must_swap, data->trans_tab_offset));
domain->hash_size = SWAPIT(domain->must_swap, data->hash_tab_size);
domain->hash_tab = (u32 *)
((char *) data + SWAPIT(domain->must_swap, data->hash_tab_offset));
break;
default: /* This is an invalid revision. */
free( data );
free( domain );
return NULL;
}
/* allocate an array to keep track of code page mappings */
domain->mapped = calloc( 1, domain->nstrings );
if( !domain->mapped ) {
free( data );
free( domain );
return NULL;
}
return domain;
}
/****************
* Set the file used for translations. Pass a NULL to disable
* translation. A new filename may be set at anytime.
* WARNING: After changing the filename you shoudl not access any data
* retrieved by gettext().
*/
int
set_gettext_file( const char *filename )
{
struct loaded_domain *domain = NULL;
if( filename && *filename ) {
if( filename[0] == '/'
#ifdef HAVE_DRIVE_LETTERS
|| ( isalpha(filename[0])
&& filename[1] == ':'
&& (filename[2] == '/' || filename[2] == '\\') )
#endif
) {
/* absolute path - use it as is */
domain = load_domain( filename );
}
else { /* relative path - append ".mo" and get dir from the environment */
char *buf = NULL;
char *dir;
dir = read_w32_registry_string( NULL,
"Control Panel\\Mingw32\\NLS",
"MODir" );
if( dir && (buf=malloc(strlen(dir)+strlen(filename)+1+3+1)) ) {
strcpy(stpcpy(stpcpy(stpcpy( buf, dir),"\\"), filename),".mo");
domain = load_domain( buf );
free(buf);
}
free(dir);
}
if( !domain ) {
return -1; }
}
if( the_domain ) {
free( the_domain->data );
free( the_domain->mapped );
free( the_domain );
the_domain = NULL;
}
the_domain = domain;
return NULL;
}
static const char*
get_string( struct loaded_domain *domain, u32 idx )
{
char *p = domain->data + SWAPIT(domain->must_swap,
domain->trans_tab[idx].offset);
/* status of domain->mapped[idx] is ignored.
* not sure about the consequences.
* perhaps mapped can entirely be removed?
*/
/* we assume, strings are already correctly
* encoded.
*/
return (const char*)p;
}
const char *
gettext( const char *msgid )
{
struct loaded_domain *domain;
size_t act = 0;
size_t top, bottom;
if( !(domain = the_domain) ) {
goto not_found;
}
/* Locate the MSGID and its translation. */
if( domain->hash_size > 2 && domain->hash_tab ) {
/* Use the hashing table. */
u32 len = strlen (msgid);
u32 hash_val = hash_string (msgid);
u32 idx = hash_val % domain->hash_size;
u32 incr = 1 + (hash_val % (domain->hash_size - 2));
u32 nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]);
if ( !nstr ) /* Hash table entry is empty. */
goto not_found;
if( SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].length) == len
&& !strcmp( msgid,
domain->data + SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].offset)) )
return get_string( domain, nstr - 1 );
for(;;) {
if (idx >= domain->hash_size - incr)
idx -= domain->hash_size - incr;
else
idx += incr;
nstr = SWAPIT(domain->must_swap, domain->hash_tab[idx]);
if( !nstr )
goto not_found; /* Hash table entry is empty. */
if ( SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].length) == len
&& !strcmp (msgid,
domain->data + SWAPIT(domain->must_swap,
domain->orig_tab[nstr - 1].offset)))
return get_string( domain, nstr-1 );
}
/* NOTREACHED */
}
/* Now we try the default method: binary search in the sorted
array of messages. */
bottom = 0;
top = domain->nstrings;
while( bottom < top ) {
int cmp_val;
act = (bottom + top) / 2;
cmp_val = strcmp(msgid, domain->data
+ SWAPIT(domain->must_swap,
domain->orig_tab[act].offset));
if (cmp_val < 0)
top = act;
else if (cmp_val > 0)
bottom = act + 1;
else
return get_string( domain, act );
}
not_found:
return msgid;
}
#if 0
unsigned int cp1, cp2;
cp1 = GetConsoleCP();
cp2 = GetConsoleOutputCP();
log_info("InputCP=%u OutputCP=%u\n", cp1, cp2 );
if( !SetConsoleOutputCP( 1252 ) )
log_info("SetConsoleOutputCP failed: %d\n", (int)GetLastError() );
cp1 = GetConsoleCP();
cp2 = GetConsoleOutputCP();
log_info("InputCP=%u OutputCP=%u after switch1\n", cp1, cp2 );
#endif
#endif /* USE_SIMPLE_GETTEXT */

View file

@ -31,7 +31,7 @@
static gint verbose = 1;
static gchar smtp_response[MSGBUFSIZE];
gint smtp_helo(gint sock, const char *hostname, gboolean use_smtp_auth)
gint smtp_helo(SockInfo *sock, const char *hostname, gboolean use_smtp_auth)
{
if (use_smtp_auth) {
sock_printf(sock, "EHLO %s\r\n", hostname);
@ -48,7 +48,7 @@ gint smtp_helo(gint sock, const char *hostname, gboolean use_smtp_auth)
}
}
gint smtp_from(gint sock, const gchar *from,
gint smtp_from(SockInfo *sock, const gchar *from,
const gchar *userid, const gchar *passwd,
gboolean use_smtp_auth)
{
@ -81,7 +81,7 @@ gint smtp_from(gint sock, const gchar *from,
return smtp_ok(sock);
}
gint smtp_rcpt(gint sock, const gchar *to)
gint smtp_rcpt(SockInfo *sock, const gchar *to)
{
gchar buf[MSGBUFSIZE];
@ -97,7 +97,7 @@ gint smtp_rcpt(gint sock, const gchar *to)
return smtp_ok(sock);
}
gint smtp_data(gint sock)
gint smtp_data(SockInfo *sock)
{
sock_printf(sock, "DATA\r\n");
if (verbose)
@ -106,7 +106,7 @@ gint smtp_data(gint sock)
return smtp_ok(sock);
}
gint smtp_rset(gint sock)
gint smtp_rset(SockInfo *sock)
{
sock_printf(sock, "RSET\r\n");
if (verbose)
@ -115,7 +115,7 @@ gint smtp_rset(gint sock)
return smtp_ok(sock);
}
gint smtp_quit(gint sock)
gint smtp_quit(SockInfo *sock)
{
sock_printf(sock, "QUIT\r\n");
if (verbose)
@ -124,7 +124,7 @@ gint smtp_quit(gint sock)
return smtp_ok(sock);
}
gint smtp_eom(gint sock)
gint smtp_eom(SockInfo *sock)
{
sock_printf(sock, ".\r\n");
if (verbose)
@ -133,7 +133,7 @@ gint smtp_eom(gint sock)
return smtp_ok(sock);
}
gint smtp_ok(gint sock)
gint smtp_ok(SockInfo *sock)
{
while ((sock_read(sock, smtp_response, sizeof(smtp_response) - 1))
!= 1) {

View file

@ -22,6 +22,8 @@
#include <glib.h>
#include "socket.h"
#define SMTPBUFSIZE 256
#define SM_OK 0
@ -32,14 +34,14 @@
#define ESMTP_SIZE 0x02
#define ESMTP_ETRN 0x04
gint smtp_helo(gint sock, const char *hostname, gboolean use_smtp_auth);
gint smtp_from(gint sock, const gchar *from, const gchar *userid,
gint smtp_helo(SockInfo *sock, const char *hostname, gboolean use_smtp_auth);
gint smtp_from(SockInfo *sock, const gchar *from, const gchar *userid,
const gchar *passwd, gboolean use_smtp_auth);
gint smtp_rcpt(gint sock, const gchar *to);
gint smtp_data(gint sock);
gint smtp_rset(gint sock);
gint smtp_quit(gint sock);
gint smtp_eom(gint sock);
gint smtp_ok(gint sock);
gint smtp_rcpt(SockInfo *sock, const gchar *to);
gint smtp_data(SockInfo *sock);
gint smtp_rset(SockInfo *sock);
gint smtp_quit(SockInfo *sock);
gint smtp_eom(SockInfo *sock);
gint smtp_ok(SockInfo *sock);
#endif /* __SMTP_H__ */

View file

@ -42,6 +42,10 @@
#include "socket.h"
#if USE_GIO
#error USE_GIO is currently not supported
#endif
#define BUFFSIZE 8192
#ifndef INET6
@ -53,7 +57,8 @@ static gint sock_connect_by_getaddrinfo (const gchar *hostname,
gushort port);
#endif
gint sock_connect_unix(const gchar *path)
gint fd_connect_unix(const gchar *path)
{
gint sock;
struct sockaddr_un addr;
@ -76,7 +81,7 @@ gint sock_connect_unix(const gchar *path)
return sock;
}
gint sock_open_unix(const gchar *path)
gint fd_open_unix(const gchar *path)
{
gint sock;
struct sockaddr_un addr;
@ -107,7 +112,7 @@ gint sock_open_unix(const gchar *path)
return sock;
}
gint sock_accept(gint sock)
gint fd_accept(gint sock)
{
struct sockaddr_in caddr;
gint caddr_len;
@ -116,11 +121,12 @@ gint sock_accept(gint sock)
return accept(sock, (struct sockaddr *)&caddr, &caddr_len);
}
gint sock_set_nonblocking_mode(gint sock, gboolean nonblock)
static gint set_nonblocking_mode(gint fd, gboolean nonblock)
{
gint flags;
flags = fcntl(sock, F_GETFL, 0);
flags = fcntl(fd, F_GETFL, 0);
if (flags < 0) {
perror("fcntl");
return -1;
@ -131,14 +137,22 @@ gint sock_set_nonblocking_mode(gint sock, gboolean nonblock)
else
flags &= ~O_NONBLOCK;
return fcntl(sock, F_SETFL, flags);
return fcntl(fd, F_SETFL, flags);
}
gboolean sock_is_nonblocking_mode(gint sock)
gint sock_set_nonblocking_mode(SockInfo *sock, gboolean nonblock)
{
g_return_val_if_fail(sock != NULL, -1);
return set_nonblocking_mode(sock->sock, nonblock);
}
static gboolean is_nonblocking_mode(gint fd)
{
gint flags;
flags = fcntl(sock, F_GETFL, 0);
flags = fcntl(fd, F_GETFL, 0);
if (flags < 0) {
perror("fcntl");
return FALSE;
@ -147,6 +161,14 @@ gboolean sock_is_nonblocking_mode(gint sock)
return ((flags & O_NONBLOCK) != 0);
}
gboolean sock_is_nonblocking_mode(SockInfo *sock)
{
g_assert(sock);
return is_nonblocking_mode(sock->sock);
}
#ifndef INET6
static gint sock_connect_by_hostname(gint sock, const gchar *hostname,
gushort port)
@ -245,7 +267,7 @@ SockInfo *sock_connect_nb(const gchar *hostname, gushort port)
#ifdef INET6
if ((sock = sock_connect_by_getaddrinfo(hostname, port)) < 0)
return NULL;
if (sock_set_nonblocking_mode(sock, TRUE) < 0) return NULL;
if (set_nonblocking_mode(sock, TRUE) < 0) return NULL;
ret = sock;
#else
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
@ -253,13 +275,13 @@ SockInfo *sock_connect_nb(const gchar *hostname, gushort port)
return NULL;
}
if (sock_set_nonblocking_mode(sock, TRUE) < 0) 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");
sock_close(sock);
close(sock);
return NULL;
}
#endif /* INET6 */
@ -292,7 +314,7 @@ SockInfo *sock_connect(const gchar *hostname, gushort port)
if (sock_connect_by_hostname(sock, hostname, port) < 0) {
if (errno != 0) perror("connect");
sock_close(sock);
close(sock);
return NULL;
}
#endif /* INET6 */
@ -356,13 +378,8 @@ SockInfo *sock_connect_with_thread(const gchar *hostname, gushort port)
}
#endif
void sock_sockinfo_free(SockInfo *sockinfo)
{
g_free(sockinfo->hostname);
g_free(sockinfo);
}
gint sock_printf(gint sock, const gchar *format, ...)
gint sock_printf(SockInfo *sock, const gchar *format, ...)
{
va_list args;
gchar buf[BUFFSIZE];
@ -374,12 +391,19 @@ gint sock_printf(gint sock, const gchar *format, ...)
return sock_write(sock, buf, strlen(buf));
}
gint sock_write(gint sock, const gchar *buf, gint len)
gint sock_write(SockInfo *sock, const gchar *buf, gint len)
{
g_return_val_if_fail(sock != NULL, -1);
return fd_write(sock->sock, buf, len);
}
gint fd_write(gint fd, const gchar *buf, gint len)
{
gint n, wrlen = 0;
while (len) {
n = write(sock, buf, len);
n = write(fd, buf, len);
if (n <= 0)
return -1;
len -= n;
@ -390,7 +414,14 @@ gint sock_write(gint sock, const gchar *buf, gint len)
return wrlen;
}
gint sock_read(gint sock, gchar *buf, gint len)
gint sock_read(SockInfo *sock, gchar *buf, gint len)
{
g_return_val_if_fail(sock != NULL, -1);
return fd_read(sock->sock, buf, len);
}
gint fd_read(gint fd, gchar *buf, gint len)
{
gchar *newline, *bp = buf;
gint n;
@ -398,11 +429,11 @@ gint sock_read(gint sock, gchar *buf, gint len)
if (--len < 1)
return -1;
do {
if ((n = recv(sock, bp, len, MSG_PEEK)) <= 0)
if ((n = recv(fd, bp, len, MSG_PEEK)) <= 0)
return -1;
if ((newline = memchr(bp, '\n', n)) != NULL)
n = newline - bp + 1;
if ((n = read(sock, bp, n)) < 0)
if ((n = read(fd, bp, n)) < 0)
return -1;
bp += n;
len -= n;
@ -412,7 +443,7 @@ gint sock_read(gint sock, gchar *buf, gint len)
return bp - buf;
}
gint sock_puts(gint sock, const gchar *buf)
gint sock_puts(SockInfo *sock, const gchar *buf)
{
gint ret;
@ -422,18 +453,45 @@ gint sock_puts(gint sock, const gchar *buf)
}
/* peek at the next socket character without actually reading it */
gint sock_peek(gint sock)
gint sock_peek(SockInfo *sock)
{
gint n;
gchar ch;
if ((n = recv(sock, &ch, 1, MSG_PEEK)) < 0)
g_return_val_if_fail(sock != NULL, -1);
if ((n = recv(sock->sock, &ch, 1, MSG_PEEK)) < 0)
return -1;
else
return ch;
}
gint sock_close(gint sock)
gint sock_close(SockInfo *sock)
{
return close(sock);
gint rc;
if (!sock)
return 0;
rc = fd_close(sock->sock);
g_free(sock->hostname);
g_free(sock);
return rc;
}
gint fd_close(gint fd)
{
return close(fd);
}
gint sock_gdk_input_add(SockInfo *sock,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data)
{
g_return_val_if_fail(sock != NULL, -1);
/* :WK: We have to change some things here becuse most likey
function() does take SockInfo * and not an gint */
return gdk_input_add(sock->sock, condition, function, data);
}

View file

@ -25,6 +25,7 @@
#endif
#include <glib.h>
#include <gdk/gdk.h> /* ugly, just needed for the GdkInputCondition et al. */
#if USE_THREADS
# include <pthread.h>
@ -43,7 +44,13 @@ typedef enum
struct _SockInfo
{
#if USE_GIO
GIOChannel *channel;
gchar *buf;
gint buflen;
#else
gint sock;
#endif
gchar *hostname;
gushort port;
ConnectionState state;
@ -54,27 +61,39 @@ struct _SockInfo
#endif
};
gint sock_set_nonblocking_mode (gint sock, gboolean nonblock);
gboolean sock_is_nonblocking_mode (gint sock);
gint sock_set_nonblocking_mode (SockInfo *sock, gboolean nonblock);
gboolean sock_is_nonblocking_mode (SockInfo *sock);
SockInfo *sock_connect_nb (const gchar *hostname, gushort port);
SockInfo *sock_connect (const gchar *hostname, gushort port);
gint sock_connect_unix (const gchar *path);
gint sock_open_unix (const gchar *path);
gint sock_accept (gint sock);
#if USE_THREADS
SockInfo *sock_connect_with_thread (const gchar *hostname, gushort port);
#endif
void sock_sockinfo_free (SockInfo *sockinfo);
gint sock_printf (gint sock, const gchar *format, ...)
gint sock_printf (SockInfo *sock, const gchar *format, ...)
G_GNUC_PRINTF(2, 3);
gint sock_write (gint sock, const gchar *buf, gint len);
gint sock_read (gint sock, gchar *buf, gint len);
gint sock_puts (gint sock, const gchar *buf);
gint sock_close (gint sock);
gint sock_write (SockInfo *sock, const gchar *buf, gint len);
gint sock_read (SockInfo *sock, gchar *buf, gint len);
gint sock_puts (SockInfo *sock, const gchar *buf);
gint sock_close (SockInfo *sock);
/* wrapper functions */
gint sock_gdk_input_add (SockInfo *sock,
GdkInputCondition condition,
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);
gint fd_accept (gint sock);
gint fd_read (gint sock, gchar *buf, gint len);
gint fd_write (gint sock, const gchar *buf, gint len);
gint fd_close (gint sock);
#endif /* __SOCKET_H__ */

View file

@ -63,6 +63,7 @@
#include "utils.h"
#include "gtkutils.h"
#include "filesel.h"
#include "manage_window.h"
#include "alertpanel.h"
#include "inputdialog.h"
#include "statusbar.h"
@ -2520,6 +2521,9 @@ static void summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
if (alertpanel(_("Exit"), _("Exit this program?"),
_("OK"), _("Cancel"), NULL)
== G_ALERTDEFAULT) {
manage_window_focus_in
(summaryview->mainwin->window,
NULL, NULL);
app_will_exit(NULL, summaryview->mainwin);
}
}

View file

@ -1028,12 +1028,43 @@ gchar **strsplit_with_quote(const gchar *str, const gchar *delim,
return str_array;
}
/*
* We need this wrapper around g_get_home_dir(), so that
* we can fix some Windoze things here. Should be done in glibc of course
* but as long as we are not able to do our own extensions to glibc, we do
* it here.
*/
gchar *get_home_dir(void)
{
#if HAVE_DOSISH_SYSTEM
static gchar *home_dir;
if (!home_dir) {
home_dir = read_w32_registry_string(NULL,
"Software\\Sylpheed", "HomeDir" );
if (!home_dir || !*home_dir) {
if (getenv ("HOMEDRIVE") && getenv("HOMEPATH")) {
const char *s = g_get_home_dir();
if (s && *s)
home_dir = g_strdup (s);
}
if (!home_dir || !*home_dir)
home_dir = g_strdup ("c:\\sylpheed");
}
debug_print("initialized home_dir to `%s'\n", home_dir);
}
return home_dir;
#else /* standard glib */
return g_get_home_dir();
#endif
}
gchar *get_rc_dir(void)
{
static gchar *rc_dir = NULL;
if (!rc_dir)
rc_dir = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S,
rc_dir = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
RC_DIR, NULL);
return rc_dir;

View file

@ -38,6 +38,35 @@
# include <wchar.h>
#endif
/* The AC_CHECK_SIZEOF() in configure fails for some machines.
* we provide some fallback values here */
#if !SIZEOF_UNSIGNED_SHORT
#undef SIZEOF_UNSIGNED_SHORT
#define SIZEOF_UNSIGNED_SHORT 2
#endif
#if !SIZEOF_UNSIGNED_INT
#undef SIZEOF_UNSIGNED_INT
#define SIZEOF_UNSIGNED_INT 4
#endif
#if !SIZEOF_UNSIGNED_LONG
#undef SIZEOF_UNSIGNED_LONG
#define SIZEOF_UNSIGNED_LONG 4
#endif
#ifndef HAVE_U32_TYPEDEF
#undef u32 /* maybe there is a macro with this name */
#if SIZEOF_UNSIGNED_INT == 4
typedef unsigned int u32;
#elif SIZEOF_UNSIGNED_LONG == 4
typedef unsigned long u32;
#else
#error no typedef for u32
#endif
#define HAVE_U32_TYPEDEF
#endif
#define CHDIR_RETURN_IF_FAIL(dir) \
{ \
if (change_dir(dir) < 0) return; \
@ -205,6 +234,7 @@ gchar **strsplit_with_quote (const gchar *str,
gint max_tokens);
/* return static strings */
gchar *get_home_dir (void);
gchar *get_rc_dir (void);
gchar *get_news_cache_dir (void);
gchar *get_imap_cache_dir (void);