erbrowser/src/browserSettings.h File Reference

browser - read/write the browser settings and configure mozilla with these settings More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ProxySettings
struct  _BrowserSettings

Defines

#define PREF_ID   NS_PREF_CONTRACTID
#define MAX_SETTINGSPATH_LENGTH   128
#define MAX_PROXY   15
#define MAX_PROXY_PORT   5
#define MAX_URL_SIZE   256
#define CONFIG_FILE_NAME   "/config"
#define STARTUP_FILE_NAME   "/startup"

Typedefs

typedef struct _ProxySettings ProxySettings
typedef struct _BrowserSettings BrowserSettings

Functions

gboolean browser_settings_init (GtkMozEmbed *b)
gboolean browser_settings_store (void)
gboolean browser_settings_get (BrowserSettings *theBrowserSettings)
gboolean browser_settings_set_mozilla_settings (BrowserSettings *theBrowserSettings)
float browser_settings_get_zoom_factor (void)
void browser_settings_set_zoom_factor (float zoom_factor)


Detailed Description

browser - read/write the browser settings and configure mozilla with these settings

<File description>="">

Definition in file browserSettings.h.


Define Documentation

#define CONFIG_FILE_NAME   "/config"

Definition at line 39 of file browserSettings.h.

#define MAX_PROXY   15

Definition at line 35 of file browserSettings.h.

#define MAX_PROXY_PORT   5

Definition at line 36 of file browserSettings.h.

#define MAX_SETTINGSPATH_LENGTH   128

Definition at line 34 of file browserSettings.h.

#define MAX_URL_SIZE   256

Definition at line 37 of file browserSettings.h.

#define PREF_ID   NS_PREF_CONTRACTID

Definition at line 33 of file browserSettings.h.

#define STARTUP_FILE_NAME   "/startup"

Definition at line 40 of file browserSettings.h.


Typedef Documentation

typedef struct _ProxySettings ProxySettings


Function Documentation

gboolean browser_settings_get ( BrowserSettings theBrowserSettings  ) 

retrieve the current content of the settingsfile

Parameters:
theBrowserSettings where the retreived values should be stored
Returns:
TRUE in case of succes

Definition at line 137 of file browserSettings.cpp.

00138 {
00139     FILE   *settings_file = NULL;
00140     gchar  *filename = NULL;
00141 
00142     BR_LOGPRINTF("entry");
00143 
00144     if (theBrowserSettings)
00145     {
00146         filename = g_strconcat(gBrowserSettingsPath, CONFIG_FILE_NAME, NULL);
00147         settings_file = fopen(filename, "r");
00148 
00149         if (settings_file)
00150         {
00151             fscanf(settings_file, "directconnection=%d\n", &theBrowserSettings->theProxySettings.direct_connection);
00152             fscanf(settings_file, "http_proxy=%s\n", &theBrowserSettings->theProxySettings.http_proxy);
00153             fscanf(settings_file, "http_proxy_port=%s\n", &theBrowserSettings->theProxySettings.http_proxy_port);
00154             fscanf(settings_file, "ftp_proxy=%s\n", &theBrowserSettings->theProxySettings.ftp_proxy);
00155             fscanf(settings_file, "ftp_proxy_port=%s\n", &theBrowserSettings->theProxySettings.ftp_proxy_port);
00156             fscanf(settings_file, "ssl_proxy=%s\n", &theBrowserSettings->theProxySettings.ssl_proxy);
00157             fscanf(settings_file, "ssl_proxy_port=%s\n", &theBrowserSettings->theProxySettings.ssl_proxy_port);
00158             fscanf(settings_file, "no_proxy_for=%s\n", &theBrowserSettings->theProxySettings.no_proxy_for);
00159             fscanf(settings_file, "zoom_factor=%f\n", &theBrowserSettings->zoom_factor);
00160 
00161             fclose(settings_file);
00162         }
00163         else
00164         {
00165             BR_ERRORPRINTF("could not open settings file %s", filename);
00166         }
00167 
00168         g_free(filename);
00169         return TRUE;
00170 
00171     }
00172     else
00173     {
00174         BR_ERRORPRINTF("input parameter == NULL");
00175         return FALSE;
00176     }
00177 }

float browser_settings_get_zoom_factor ( void   ) 

Method used to retrieve the zoomfactor used by the browser .

Returns:
zoomfactor

Definition at line 362 of file browserSettings.cpp.

00363 {
00364     return gBrowserSettings.zoom_factor;
00365 }

gboolean browser_settings_init ( GtkMozEmbed *  b  ) 

creates (if needed) the directory on the system used to store the settings files retrieve the current browser settings and use these to configure mozilla/Gecko.

Parameters:
b reference to the MozEmbed widget
Returns:
TRUE in case of succes

Definition at line 66 of file browserSettings.cpp.

00067 {
00068     gboolean returnValue = FALSE;
00069     gchar  *directory;
00070     gchar  *browserUserHomePath;
00071     gchar  *filename;
00072     BrowserSettings *theBrowserSettings;
00073 
00074     BR_LOGPRINTF("entry");
00075 
00076     browserUserHomePath = PR_GetEnv("HOME");
00077 
00078     if (!browserUserHomePath)
00079     {
00080         BR_ERRORPRINTF("Failed to get HOME");
00081         return returnValue;
00082     }
00083 
00084     // create directory [g_strconcat alllocates memory]
00085     directory = g_strconcat(browserUserHomePath, "/.Browser", NULL);
00086     mkdir(directory, 0755);
00087 
00088     // store the path value
00089     if (strlen(directory) < MAX_SETTINGSPATH_LENGTH)
00090     {
00091         g_strlcpy(gBrowserSettingsPath, directory, MAX_SETTINGSPATH_LENGTH);
00092     }
00093 
00094     g_free(directory);
00095 
00096     BR_LOGPRINTF("path %s", gBrowserSettingsPath);
00097 
00098     filename = g_strconcat(gBrowserSettingsPath, CONFIG_FILE_NAME, NULL);
00099 
00100     theBrowserSettings = &gBrowserSettings;
00101 
00102     if (g_file_test(filename, G_FILE_TEST_EXISTS) == TRUE)
00103     {
00104         //retrieve the current content of the settingsfile 
00105         returnValue = browser_settings_get(theBrowserSettings);
00106     }
00107     else
00108     {
00109         browser_settings_get_defaults(theBrowserSettings);
00110         theBrowserSettings->zoom_factor = 1.0;
00111         returnValue = TRUE;
00112     }
00113 
00114     //only for debug reasons
00115     browser_display_settings(&gBrowserSettings);
00116 
00117     browser_settings_set_mozilla_settings(theBrowserSettings);
00118     
00119     // MvdW: Quick hack to allow XHTML navigation with hardkeys:
00120     //  made focus_ring visible, so links are outlined
00121     //  this needs to be moved to more generic settings functions
00122     //  which also need to read the registry for proxy settings and such
00123     mozilla_pref_set_int("browser.display.focus_ring_width", 3);
00124     mozilla_pref_set_boolean("browser.display.focus_ring_on_anything", TRUE);
00125 
00126     g_free(filename);
00127 
00128     return returnValue;
00129 }

Here is the call graph for this function:

gboolean browser_settings_set_mozilla_settings ( BrowserSettings theBrowserSettings  ) 

configure mozilla with the current settings

Parameters:
theBrowserSettings the current settings
Returns:
TRUE in case of succes

Definition at line 282 of file browserSettings.cpp.

00283 {
00284     // set proxy preferences 
00285     browser_set_proxy_prefs(&theBrowserSettings->theProxySettings);
00286     mozilla_save_prefs();
00287     return TRUE;
00288 }

Here is the call graph for this function:

void browser_settings_set_zoom_factor ( float  zoom_factor  ) 

Method used to set the the zoomfactor used by the browser .

Returns:
void

Definition at line 367 of file browserSettings.cpp.

00368 {
00369     if (zoom_factor >= 0)
00370     {
00371         gBrowserSettings.zoom_factor = zoom_factor;
00372     }
00373 }

gboolean browser_settings_store ( void   ) 

write the current browser settings into $home/.Browser/config

Returns:
TRUE in case of succes


Generated on Sun Dec 14 17:14:47 2008 by  doxygen 1.5.6