TEST_FIXTURE(EnchantGetRegistryValue_TestFixture, 
             GetRegistryValue_NullKey_Null)
{
  SetUserRegistryValue("hello");

  char * value = enchant_get_registry_value("Test", NULL);

  CHECK(value == NULL);
}
Example #2
0
void configure_enchant_provider(EnchantProvider * me, const char *dir_name)
{
#if defined(_WIN32)
    const WCHAR* aspell_module_name = L"aspell-15.dll";
    HMODULE aspell_module = NULL;
    char* szModule;

    /* first try load from registry path */
    szModule = enchant_get_registry_value ("Aspell", "Module");
    if(szModule)
    {
        WCHAR* wszModule;

        wszModule = g_utf8_to_utf16 (szModule, -1, NULL, NULL, NULL);
        aspell_module = LoadLibrary(wszModule);
        g_free(wszModule);
    }

    if (aspell_module == NULL)
    {
        /* next try load from aspell registry path */
        WCHAR* wszDirectory = GetRegistryValue (HKEY_LOCAL_MACHINE, L"Software\\Aspell", L"Path");
        if(wszDirectory)
        {
            aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
            g_free(wszDirectory);
        }
    }

    if (aspell_module == NULL)
    {
        /* then try from same directory as provider */
        WCHAR* wszDirectory = GetDirectoryOfThisLibrary();
        if(wszDirectory)
        {
            aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
            g_free(wszDirectory);
        }
    }

    if (aspell_module == NULL)
    {
        /* then try default lookup */
        aspell_module = LoadLibrary(aspell_module_name);
    }

    if (aspell_module == NULL)
    {
        /* we can't seem to load aspell. Avoid late binding problems later */
        g_warning("Unable to load library aspell-15.dll.");
        me->request_dict = NULL;
        me->dispose_dict = NULL;
        me->list_dicts = NULL;
    }
#endif

}
TEST_FIXTURE(EnchantGetRegistryValue_TestFixture, 
             GetRegistryValue_MachineOnly_ValueFromMachine)
{
  SetMachineRegistryValue("world");
  char * value = enchant_get_registry_value("Test", "Value");

  CHECK(value);
  CHECK_EQUAL("world", value);

  g_free(value);
}
TEST_FIXTURE(EnchantGetRegistryValue_TestFixture, 
             GetRegistryValue_UserOnly_ValueFromUser)
{
  SetUserRegistryValue("hello");
  char * value = enchant_get_registry_value("Test", "Value");

  CHECK(value);
  CHECK_EQUAL("hello", value);

  g_free(value);
}
TEST_FIXTURE(EnchantGetRegistryValue_TestFixture, 
             GetRegistryValue_UserEmptyAndMachineNotSet_Null)
{
  SetUserRegistryValue("");

  char * value = enchant_get_registry_value("Test", "Value");

  CHECK(!value);

  g_free(value);
}
Example #6
0
gboolean load_library(EnchantProvider * me, const char *dir_name, const WCHAR *aspell_module_name)
{
    HMODULE aspell_module = NULL;
    char* szModule;

    /* first try load from registry path */
   	szModule = enchant_get_registry_value ("Aspell", "Module");
    if(szModule)
    {
        WCHAR* wszModule;

	    wszModule = g_utf8_to_utf16 (szModule, -1, NULL, NULL, NULL);
        aspell_module = LoadLibraryW(wszModule);
        g_free(wszModule);
    }

    if (aspell_module == NULL)
        {
            /* next try load from aspell registry path */
            WCHAR* wszDirectory = GetRegistryValue (HKEY_LOCAL_MACHINE, L"Software\\Aspell", L"Path");
            if(wszDirectory)
                {
                    aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
                    g_free(wszDirectory);
                }
        }

    if (aspell_module == NULL)
        {
            /* then try from same directory as provider */
            WCHAR* wszDirectory = GetDirectoryOfThisLibrary();
            if(wszDirectory)
                {
                    aspell_module = LoadLibraryFromPath(wszDirectory, aspell_module_name);
                    g_free(wszDirectory);
                }
        }

    if (aspell_module == NULL) 
        {
            /* then try default lookup */
            aspell_module = LoadLibraryW(aspell_module_name);
        }

    if (aspell_module == NULL) 
        {
	        return FALSE;
        }
    return TRUE;
}
Example #7
0
static GSList *
ispell_checker_get_dictionary_dirs (void)
{
	GSList *dirs = NULL;

	{
		GSList *config_dirs, *iter;

		config_dirs = enchant_get_user_config_dirs ();
		
		for (iter = config_dirs; iter; iter = iter->next)
			{
				dirs = g_slist_append (dirs, g_build_filename ((const gchar *)iter->data, 
									       ENCHANT_ISPELL_HOME_DIR, NULL));
			}

		g_slist_foreach (config_dirs, (GFunc)g_free, NULL);
		g_slist_free (config_dirs);
	}

	/* until I work out how to link the modules against enchant in MacOSX - fjf
	 */
#ifndef XP_TARGET_COCOA
	char * ispell_prefix = NULL;

	/* Look for explicitly set registry values */
	ispell_prefix = enchant_get_registry_value ("Ispell", "Data_Dir");
	if (ispell_prefix)
		dirs = g_slist_append (dirs, ispell_prefix);

	/* Dynamically locate library and search for modules relative to it. */
	char * enchant_prefix = enchant_get_prefix_dir();
	if(enchant_prefix)
		{
			ispell_prefix = g_build_filename(enchant_prefix, "share", "enchant", "ispell", NULL);
			g_free(enchant_prefix);
			dirs = g_slist_append (dirs, ispell_prefix);
		}
#endif

#ifdef ENCHANT_ISPELL_DICT_DIR
	dirs = g_slist_append (dirs, g_strdup (ENCHANT_ISPELL_DICT_DIR));
#endif

	return dirs;
}
Example #8
0
static GSList *
uspell_checker_get_dictionary_dirs (EnchantBroker * broker)
{
	GSList *dirs = NULL;

	{
		GSList *config_dirs, *iter;

		config_dirs = enchant_get_user_config_dirs ();
		
		for (iter = config_dirs; iter; iter = iter->next)
			{
				dirs = g_slist_append (dirs, g_build_filename ((const gchar *)iter->data, 
									       "uspell", NULL));
			}

		g_slist_foreach (config_dirs, (GFunc)g_free, NULL);
		g_slist_free (config_dirs);
	}

	{
		const gchar* const * system_data_dirs = g_get_system_data_dirs ();
		const gchar* const * iter;

		for (iter = system_data_dirs; *iter; iter++)
			{
				dirs = g_slist_append (dirs, g_build_filename (*iter, "uspell", "dicts", NULL));
			}
	}

	/* until I work out how to link the modules against enchant in MacOSX - fjf
	 */
#ifndef XP_TARGET_COCOA
	char * uspell_prefix = NULL;

	/* Look for explicitly set registry values */
	uspell_prefix = enchant_get_registry_value ("Uspell", "Data_Dir");
	if (uspell_prefix)
		dirs = g_slist_append (dirs, uspell_prefix);

	/* Dynamically locate library and search for modules relative to it. */
	char * enchant_prefix = enchant_get_prefix_dir();
	if(enchant_prefix)
		{
			uspell_prefix = g_build_filename(enchant_prefix, "share", "enchant", "uspell", NULL);
			g_free(enchant_prefix);
			dirs = g_slist_append (dirs, uspell_prefix);
		}
#endif

#ifdef ENCHANT_USPELL_DICT_DIR
	dirs = g_slist_append (dirs, g_strdup (ENCHANT_USPELL_DICT_DIR));
#endif

	{
		GSList *config_dirs, *iter;

		config_dirs = enchant_get_dirs_from_param (broker, "enchant.uspell.dictionary.path");
		
		for (iter = config_dirs; iter; iter = iter->next)
			{
				dirs = g_slist_append (dirs, g_strdup ((const gchar *)iter->data));
			}

		g_slist_foreach (config_dirs, (GFunc)g_free, NULL);
		g_slist_free (config_dirs);
	}

	return dirs;
}