diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-09-05 07:27:20 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-09-05 07:27:20 +0000 |
commit | 51f886e4c8b44242b10c057a1af70f66f28bb2e6 (patch) | |
tree | 95285904d3bbe1bb65dee4898fb1ec31c86d8390 /libsylph | |
parent | fa466fd5e1e6b481f6249979cfb7397caa875f5c (diff) |
made query-password function UI independent.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@546 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/utils.c | 31 | ||||
-rw-r--r-- | libsylph/utils.h | 12 |
2 files changed, 42 insertions, 1 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c index dc72b814..ac4ffa6c 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -3263,6 +3263,25 @@ size_t my_strftime(gchar *s, size_t max, const gchar *format, return strftime(s, max, format, tm); } +/* user input */ + +static QueryPasswordFunc query_password_func = NULL; + +void set_input_query_password_func(QueryPasswordFunc func) +{ + query_password_func = func; +} + +gchar *input_query_password(const gchar *server, const gchar *user) +{ + if (query_password_func) + return query_password_func(server, user); + else + return NULL; +} + +/* logging */ + static FILE *log_fp = NULL; void set_log_file(const gchar *filename) @@ -3340,6 +3359,18 @@ void debug_print(const gchar *format, ...) g_print("%s", buf); } +void print_status(const gchar *format, ...) +{ + va_list args; + gchar buf[BUFFSIZE]; + + va_start(args, format); + g_vsnprintf(buf, sizeof(buf), format, args); + va_end(args); + + log_show_status_func(buf); +} + #define TIME_LEN 11 void log_print(const gchar *format, ...) diff --git a/libsylph/utils.h b/libsylph/utils.h index fbda26a3..ee394083 100644 --- a/libsylph/utils.h +++ b/libsylph/utils.h @@ -176,7 +176,9 @@ gint g_chmod (const gchar *path, perror(func); \ } -typedef void (*LogFunc) (const gchar *str); +typedef gchar * (*QueryPasswordFunc) (const gchar *server, + const gchar *user); +typedef void (*LogFunc) (const gchar *str); /* for macro expansion */ #define Str(x) #x @@ -470,6 +472,12 @@ size_t my_strftime (gchar *s, const gchar *format, const struct tm *tm); +/* user input */ +void set_input_query_password_func (QueryPasswordFunc func); + +gchar *input_query_password (const gchar *server, + const gchar *user); + /* logging */ void set_log_file (const gchar *filename); void close_log_file (void); @@ -485,6 +493,8 @@ void set_log_ui_func (LogFunc print_func, void set_log_show_status_func (LogFunc status_func); void debug_print (const gchar *format, ...) G_GNUC_PRINTF(1, 2); +void print_status (const gchar *format, ...) G_GNUC_PRINTF(1, 2); + void log_print (const gchar *format, ...) G_GNUC_PRINTF(1, 2); void log_message (const gchar *format, ...) G_GNUC_PRINTF(1, 2); void log_warning (const gchar *format, ...) G_GNUC_PRINTF(1, 2); |