[evolution/gnome-2-30] [win32] Implement --reinstall, --show-icons, --hide-icons options to be used by windows default appl
- From: Fridrich Strba <strba src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-2-30] [win32] Implement --reinstall, --show-icons, --hide-icons options to be used by windows default appl
- Date: Tue, 18 May 2010 15:01:46 +0000 (UTC)
commit 02564bb45b4a4ceac0bdb27ff80a26e65590d220
Author: Fridrich Å trba <fridrich strba bluewin ch>
Date: Tue May 18 16:57:11 2010 +0200
[win32] Implement --reinstall, --show-icons, --hide-icons options
to be used by windows default application setting dialogue
e-util/e-win32-defaults.c | 129 +++++++++++++++++++++------------------------
shell/main.c | 28 ++++++++++
2 files changed, 89 insertions(+), 68 deletions(-)
---
diff --git a/e-util/e-win32-defaults.c b/e-util/e-win32-defaults.c
index 99b19d1..be494bf 100644
--- a/e-util/e-win32-defaults.c
+++ b/e-util/e-win32-defaults.c
@@ -56,45 +56,46 @@ _e_register_mailto_structure (HKEY hKey)
static HKEY tmp_subkey = (HKEY) INVALID_HANDLE_VALUE;
if ((returnValue = RegSetValueExA (hKey, NULL, 0, REG_SZ, (const BYTE *)"URL:MailTo Protocol", strlen ("URL:MailTo Protocol") + 1)))
- return;
+ goto cleanup;
if ((returnValue = RegSetValueExA (hKey, "EditFlags", 0, REG_BINARY, editFlags, G_N_ELEMENTS (editFlags))))
- return;
+ goto cleanup;
if ((returnValue = RegSetValueExA (hKey, "URL Protocol", 0, REG_SZ, (const BYTE *)"", strlen ("") + 1)))
- return;
+ goto cleanup;
RegFlushKey (hKey);
if ((returnValue = RegCreateKeyExA (hKey, "DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &tmp_subkey, &dwDisposition)))
- return;
+ goto cleanup;
evolutionBinary = _e_win32_sanitize_path (g_build_path (G_DIR_SEPARATOR_S, _e_get_bindir (), EVOBINARY, NULL));
defaultIcon = g_strconcat (evolutionBinary, ",1", NULL);
- g_free (evolutionBinary);
- if ((returnValue = RegSetValueExA (tmp_subkey, NULL, 0, REG_SZ, (const BYTE *)defaultIcon, strlen (defaultIcon) + 1))) {
- g_free (defaultIcon);
- return;
- }
- g_free (defaultIcon);
+
+ if ((returnValue = RegSetValueExA (tmp_subkey, NULL, 0, REG_SZ, (const BYTE *)defaultIcon, strlen (defaultIcon) + 1)))
+ goto cleanup;
+
RegFlushKey (tmp_subkey);
RegCloseKey (tmp_subkey);
if ((returnValue = RegCreateKeyExA (hKey, "shell\\open\\command", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &tmp_subkey, &dwDisposition)))
- return;
+ goto cleanup;
evolutionBinary = _e_win32_sanitize_path (g_build_path (G_DIR_SEPARATOR_S, _e_get_bindir (), EVOBINARY, NULL));
mailtoCommand = g_strconcat("\"", evolutionBinary, "\" --component=mail mailto:\%1", NULL);
- g_free (evolutionBinary);
- if ((returnValue = RegSetValueExA (tmp_subkey, NULL, 0, REG_SZ, (const BYTE *)mailtoCommand, strlen(mailtoCommand) + 1))) {
- g_free (mailtoCommand);
- return;
- }
- g_free (mailtoCommand);
+
+ if ((returnValue = RegSetValueExA (tmp_subkey, NULL, 0, REG_SZ, (const BYTE *)mailtoCommand, strlen(mailtoCommand) + 1)))
+ goto cleanup;
+
RegFlushKey (tmp_subkey);
RegCloseKey (tmp_subkey);
+
+cleanup:
+ g_free (defaultIcon);
+ g_free (evolutionBinary);
+ g_free (mailtoCommand);
}
static void
@@ -106,8 +107,9 @@ _e_win32_register_mailer_impl (WINBOOL system)
gchar *dllPath = NULL;
gchar *evolutionBinary = NULL;
gchar *openCommand = NULL;
- gchar *setDefaultCommand = NULL;
- gchar *unsetDefaultCommand = NULL;
+ gchar *reinstallCommand = NULL;
+ gchar *showIconsCommand = NULL;
+ gchar *hideIconsCommand = NULL;
static HKEY reg_key = (HKEY) INVALID_HANDLE_VALUE;
static HKEY reg_subkey = (HKEY) INVALID_HANDLE_VALUE;
@@ -115,100 +117,91 @@ _e_win32_register_mailer_impl (WINBOOL system)
if ((returnValue = RegCreateKeyExA (system ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
"Software\\Clients\\Mail\\" CANONICALNAME, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, ®_key, &dwDisposition)))
- return;
+ goto cleanup;
if ((returnValue = RegSetValueExA (reg_key, NULL, 0, REG_SZ, (const BYTE *)CANONICALNAME, strlen(CANONICALNAME) + 1)))
- return;
+ goto cleanup;
dllPath = _e_win32_sanitize_path (g_build_path(G_DIR_SEPARATOR_S, _e_get_bindir (), EUTILDLL, NULL));
- if ((returnValue = RegSetValueExA (reg_key, "DLLPath", 0, REG_SZ, (const BYTE *)dllPath, strlen (dllPath) + 1))) {
- g_free (dllPath);
- return;
- }
- g_free(dllPath);
+
+ if ((returnValue = RegSetValueExA (reg_key, "DLLPath", 0, REG_SZ, (const BYTE *)dllPath, strlen (dllPath) + 1)))
+ goto cleanup;
RegFlushKey (reg_key);
if ((returnValue = RegCreateKeyExA (reg_key, "DefaultIcon", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, ®_subkey, &dwDisposition)))
- return;
+ goto cleanup;
evolutionBinary = _e_win32_sanitize_path (g_build_path (G_DIR_SEPARATOR_S, _e_get_bindir (), EVOBINARY, NULL));
defaultIcon = g_strconcat(evolutionBinary, ",0", NULL);
- g_free (evolutionBinary);
- if ((returnValue = RegSetValueExA (reg_subkey, NULL, 0, REG_SZ, (const BYTE *)defaultIcon, strlen (defaultIcon) + 1))) {
- g_free (defaultIcon);
- return;
- }
+
+ if ((returnValue = RegSetValueExA (reg_subkey, NULL, 0, REG_SZ, (const BYTE *)defaultIcon, strlen (defaultIcon) + 1)))
+ goto cleanup;
+
RegFlushKey (reg_subkey);
RegCloseKey (reg_subkey);
if ((returnValue = RegCreateKeyExA (reg_key, "shell\\open\\command", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, ®_subkey, &dwDisposition)))
- return;
+ goto cleanup;
- evolutionBinary = _e_win32_sanitize_path (g_build_path (G_DIR_SEPARATOR_S, _e_get_bindir (), EVOBINARY, NULL));
- openCommand = g_strconcat("\"", evolutionBinary, "\" --component=mail", NULL);
- g_free (evolutionBinary);
- if ((returnValue = RegSetValueExA (reg_subkey, NULL, 0, REG_SZ, (const BYTE *)openCommand, strlen (openCommand) + 1))) {
- g_free (openCommand);
- return;
- }
- g_free (openCommand);
+ if ((returnValue = RegSetValueExA (reg_subkey, NULL, 0, REG_SZ, (const BYTE *)openCommand, strlen (openCommand) + 1)))
+ goto cleanup;
RegFlushKey (reg_subkey);
RegCloseKey (reg_subkey);
if ((returnValue = RegCreateKeyExA (reg_key, "InstallInfo", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, ®_subkey, &dwDisposition)))
- return;
-
- dllPath = _e_win32_sanitize_path (g_build_path(G_DIR_SEPARATOR_S, _e_get_bindir (), EUTILDLL, NULL));
-
- setDefaultCommand = g_strconcat ("%SystemRoot%\\system32\\rundll32.exe \"", dllPath, "\",_e_win32_set_default_mailer", NULL);
- unsetDefaultCommand = g_strconcat ("%SystemRoot%\\system32\\rundll32.exe \"", dllPath, "\",_e_win32_unset_default_mailer", NULL);
- g_free (dllPath);
+ goto cleanup;
- if ((returnValue = RegSetValueExA (reg_subkey, "ReinstallCommand", 0, REG_EXPAND_SZ, (const BYTE *)setDefaultCommand, strlen (setDefaultCommand) + 1))) {
- g_free (setDefaultCommand);
- g_free (unsetDefaultCommand);
- return;
- }
+ reinstallCommand = g_strconcat ("\"", evolutionBinary, "\" --reinstall", NULL);
+
+ if ((returnValue = RegSetValueExA (reg_subkey, "ReinstallCommand", 0, REG_EXPAND_SZ, (const BYTE *)reinstallCommand, strlen (reinstallCommand) + 1)))
+ goto cleanup;
+
+
+ showIconsCommand = g_strconcat ("\"", evolutionBinary, "\" --show-icons", NULL);
- if ((returnValue = RegSetValueExA (reg_subkey, "ShowIconsCommand", 0, REG_EXPAND_SZ, (const BYTE *)setDefaultCommand, strlen (setDefaultCommand) + 1))) {
- g_free (setDefaultCommand);
- g_free (unsetDefaultCommand);
- return;
- }
+ if ((returnValue = RegSetValueExA (reg_subkey, "ShowIconsCommand", 0, REG_EXPAND_SZ, (const BYTE *)showIconsCommand, strlen (showIconsCommand) + 1)))
+ goto cleanup;
- if ((returnValue = RegSetValueExA (reg_subkey, "HideIconsCommand", 0, REG_EXPAND_SZ, (const BYTE *)unsetDefaultCommand, strlen (unsetDefaultCommand) + 1))) {
- g_free (setDefaultCommand);
- g_free (unsetDefaultCommand);
- return;
- }
- g_free (setDefaultCommand);
- g_free (unsetDefaultCommand);
+ hideIconsCommand = g_strconcat ("\"", evolutionBinary, "\" --hide-icons", NULL);
+
+ if ((returnValue = RegSetValueExA (reg_subkey, "HideIconsCommand", 0, REG_EXPAND_SZ, (const BYTE *)hideIconsCommand, strlen (hideIconsCommand) + 1)))
+ goto cleanup;
+
i = 1;
if ((returnValue = RegSetValueExA (reg_subkey, "IconsVisible", 0, REG_DWORD, (BYTE*)&i, sizeof (i))))
- return;
+ goto cleanup;
RegFlushKey (reg_subkey);
RegCloseKey (reg_subkey);
if ((returnValue = RegCreateKeyExA (reg_key, "Protocols\\mailto", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, ®_subkey, &dwDisposition)))
- return;
+ goto cleanup;
if ((returnValue = RegSetValueExA (reg_key, NULL, 0, REG_SZ, (const BYTE *)CANONICALNAME, strlen (CANONICALNAME) + 1)))
- return;
+ goto cleanup;
_e_register_mailto_structure (reg_subkey);
RegCloseKey (reg_subkey);
RegCloseKey (reg_key);
+
+cleanup:
+ g_free (defaultIcon);
+ g_free (dllPath);
+ g_free (evolutionBinary);
+ g_free (openCommand);
+ g_free (reinstallCommand);
+ g_free (showIconsCommand);
+ g_free (showIconsCommand);
}
void
diff --git a/shell/main.c b/shell/main.c
index b3fdc7a..f5d9061 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -80,6 +80,11 @@
#endif
/* Command-line options. */
+#ifdef G_OS_WIN32
+static gboolean reinstall = FALSE;
+static gboolean show_icons = FALSE;
+static gboolean hide_icons = FALSE;
+#endif /* G_OS_WIN32 */
static gboolean express_mode = FALSE;
static gboolean start_online = FALSE;
static gboolean start_offline = FALSE;
@@ -321,6 +326,14 @@ setup_segv_redirect (void)
#endif
static GOptionEntry entries[] = {
+#ifdef G_OS_WIN32
+ { "--reinstall", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &reinstall,
+ NULL, NULL },
+ { "--show-icons", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_icons,
+ NULL, NULL },
+ { "--hide-icons", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &hide_icons,
+ NULL, NULL },
+#endif /* G_OS_WIN32 */
{ "component", 'c', 0, G_OPTION_ARG_STRING, &requested_view,
N_("Start Evolution activating the specified component"), NULL },
{ "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry,
@@ -490,6 +503,21 @@ main (gint argc, gchar **argv)
_e_win32_register_mailer ();
+ if (reinstall) {
+ _e_win32_set_default_mailer ();
+ exit (0);
+ }
+
+ if (show_icons) {
+ _e_win32_set_default_mailer ();
+ exit (0);
+ }
+
+ if (hide_icons) {
+ _e_win32_unset_default_mailer ();
+ exit (0);
+ }
+
if (strcmp (gettext (""), "") == 0) {
/* No message catalog installed for the current locale
* language, so don't bother with the localisations
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]