aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2012-04-23 09:36:42 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2012-04-23 09:36:42 +0000
commit53625e2a9ca3c64ec08daf1d7233551c166fdbdf (patch)
treef82e186852d635a5e90356c547484c31707aebdb /libsylph
parent51b29ad3772d54b8f1e841c0c84df703eed21c21 (diff)
win32: added an option to play sound when new messages arrive.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3053 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/libsylph-0.def1
-rw-r--r--libsylph/prefs_common.c4
-rw-r--r--libsylph/prefs_common.h3
-rw-r--r--libsylph/utils.c21
-rw-r--r--libsylph/utils.h9
5 files changed, 35 insertions, 3 deletions
diff --git a/libsylph/libsylph-0.def b/libsylph/libsylph-0.def
index 9cc352a3..78fd5072 100644
--- a/libsylph/libsylph-0.def
+++ b/libsylph/libsylph-0.def
@@ -698,3 +698,4 @@ EXPORTS
procmsg_add_messages_from_queue @ 696
to_human_readable_buf @ 697
folder_item_is_trash @ 698
+ play_sound @ 699
diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c
index 7bcd0cae..0cd21531 100644
--- a/libsylph/prefs_common.c
+++ b/libsylph/prefs_common.c
@@ -47,6 +47,10 @@ static PrefParam param[] = {
P_BOOL},
{"newmsg_notify_command", NULL, &prefs_common.newmsg_notify_cmd,
P_STRING},
+ {"enable_newmsg_notify_sound", "FALSE",
+ &prefs_common.enable_newmsg_notify_sound, P_BOOL},
+ {"newmsg_notify_sound", NULL, &prefs_common.newmsg_notify_sound,
+ P_STRING},
{"inc_local", "FALSE", &prefs_common.inc_local, P_BOOL},
{"filter_on_inc_local", "TRUE", &prefs_common.filter_on_inc, P_BOOL},
diff --git a/libsylph/prefs_common.h b/libsylph/prefs_common.h
index 6c62609c..31f65b46 100644
--- a/libsylph/prefs_common.h
+++ b/libsylph/prefs_common.h
@@ -334,6 +334,9 @@ struct _PrefsCommon
gchar *prev_open_dir;
gchar *prev_save_dir;
gchar *prev_folder_dir;
+
+ gboolean enable_newmsg_notify_sound; /* Receive */
+ gchar *newmsg_notify_sound; /* Receive */
};
extern PrefsCommon prefs_common;
diff --git a/libsylph/utils.c b/libsylph/utils.c
index ac00e03e..f8431a3e 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2010 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -4248,6 +4248,25 @@ gint open_uri(const gchar *uri, const gchar *cmdline)
return 0;
}
+gint play_sound(const gchar *file, gboolean async)
+{
+#ifdef G_OS_WIN32
+ wchar_t *wfile;
+ DWORD flag = SND_FILENAME;
+
+ wfile = g_utf8_to_utf16(file, -1, NULL, NULL, NULL);
+ if (wfile == NULL)
+ return -1;
+ if (async)
+ flag |= SND_ASYNC;
+ else
+ flag |= SND_SYNC;
+ PlaySoundW(wfile, NULL, flag);
+ g_free(wfile);
+#endif
+ return 0;
+}
+
time_t remote_tzoffset_sec(const gchar *zone)
{
static gchar ustzstr[] = "PSTPDTMSTMDTCSTCDTESTEDT";
diff --git a/libsylph/utils.h b/libsylph/utils.h
index 14b289be..a67a807a 100644
--- a/libsylph/utils.h
+++ b/libsylph/utils.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2010 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -502,7 +502,12 @@ gint execute_print_file (const gchar *file);
gchar *get_command_output (const gchar *cmdline);
/* open URI with external browser */
-gint open_uri(const gchar *uri, const gchar *cmdline);
+gint open_uri (const gchar *uri,
+ const gchar *cmdline);
+
+/* play sound */
+gint play_sound (const gchar *file,
+ gboolean async);
/* time functions */
time_t remote_tzoffset_sec (const gchar *zone);