erbrowser/src/main.cpp File Reference

browser - E-reader browser startup More...

#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "browserTypes.h"
#include <pthread.h>
#include "pagebar.h"
#include <liberdm/display.h>
#include "browser.h"
#include "mozilla_api.h"
#include "selection.h"
#include "find.h"
#include "timingInfo.h"
#include "browserSettings.h"
#include "languages.h"
#include "ipcServer.h"
#include "toolbar.h"
#include <liberipc/eripcbusyd.h>
#include <liberipc/eripccontentlister.h>
#include "contentLister.h"
#include "displayUpdate.h"
#include "browserLog.h"
#include "erbusy.h"

Go to the source code of this file.

Functions

guint on_mainWindow_keypress (GtkWidget *widget, GdkEventKey *event, Ereader *reader)
int main (int argc, char **argv)

Variables

static EreadergEreader


Detailed Description

browser - E-reader browser startup

<File description>="">

Definition in file main.cpp.


Function Documentation

int main ( int  argc,
char **  argv 
)

GTK & APP startup

Parameters:
Manifest File
URL location of the first file that needs to be displayed
Returns:
A value of 0 indicates success

Definition at line 67 of file main.cpp.

00068 {
00069     bool    initialized;
00070     char   *input_URL = NULL;
00071     char   *manifest = NULL;
00072     int     returnValue = 0;
00073 
00074     // init threads - needed for toolbar service handling
00075     g_thread_init(NULL);
00076     gdk_threads_init();
00077 
00078     BR_LOGPRINTF("gtk threads init");
00079 
00080 #ifdef TIMING_INFORMATION_ENABLED
00081     timing_init();
00082 #endif //TIMING_INFORMATION_ENABLED
00083 
00084     gtk_init(&argc, &argv);
00085 
00086     languagesInit();
00087 
00088     //setup the erbusy deamon interaction
00089     erbusy_init();
00090 
00091     if (argc > 1)
00092     {
00093         BR_LOGPRINTF("argc = %d  argv[1] = %s", argc, argv[1]);
00094         if (argv[1] && strlen(argv[1]))
00095         {
00096             manifest = g_strdup(argv[1]);
00097         }            
00098     }
00099 
00100     if (argc > 2)
00101     {
00102         BR_LOGPRINTF("argc = %d  argv[2] = %s\n", argc, argv[2]);
00103         input_URL = g_strdup(argv[2]);
00104     }
00105 
00106     gEreader = new_gtk_ereader(manifest, input_URL);
00107 
00108     if (gEreader)
00109     {
00110         BR_LOGPRINTF("ereader_init gEreader 0x%x gEreader->pageStatus 0x%x", gEreader, gEreader->pageStatus);
00111 
00112         // init mozilla settings specific for this ereader device
00113         initialized = browser_settings_init(GTK_MOZ_EMBED(gEreader->mozEmbed));
00114 
00115         BR_LOGPRINTF("main -- browser_settings_init returned %s", (initialized == TRUE) ? "TRUE" : "FALSE");
00116 
00117         if (initialized == TRUE)
00118         {
00119             if (ipc_InstallIpcServer(gEreader) == TRUE)
00120             {
00121                 //setup the contentlister server interaction
00122                 contentlister_init();
00123                 //setup the toolbar server interaction 
00124                 toolbar_init();
00125 
00126                 //startup => busy
00127                 erbusy_blink();
00128 
00129                 //setup the pagebar interaction
00130                 pagebar_init();
00131 
00132 
00133                 BR_LOGPRINTF("ereader_init gEreader 0x%x gEreader->pageStatus 0x%x", gEreader, gEreader->pageStatus);
00134                 gdk_threads_enter();
00135                 gtk_main();
00136                 gdk_threads_leave();
00137             }
00138             else
00139             {
00140                 BR_ERRORPRINTF("browser_toolbar_start_listening returned FALSE");
00141                 returnValue = 1;
00142             }
00143         }
00144         else
00145         {
00146             BR_ERRORPRINTF("browser_settings_init returned FALSE");
00147             returnValue = 1;
00148         }
00149     }
00150     else
00151     {
00152         BR_ERRORPRINTF("new_gtk_ereader returned NULL");
00153         returnValue = 1;
00154     }
00155 
00156     if (input_URL)
00157     {
00158         g_free(input_URL);
00159     }
00160 
00161 #ifdef TIMING_INFORMATION_ENABLED
00162     timing_destroy();
00163 #endif //TIMING_INFORMATION_ENABLED
00164 
00165     return returnValue;
00166 }

Here is the call graph for this function:

guint on_mainWindow_keypress ( GtkWidget *  widget,
GdkEventKey *  event,
Ereader reader 
)

Definition at line 171 of file main.cpp.

00172 {
00173     GtkWidget *mozEmbed;
00174     int     returnValue = 0;
00175 
00176     int     pagecount;
00177     int     currentpage;
00178     int     newpage;
00179         int     offset;
00180 
00181     BR_LOGPRINTF("on_mainWindow_keypress - event 0x%xn", event->keyval);
00182 
00183     mozEmbed = gEreader->mozEmbed;
00184 
00185     switch (event->keyval)
00186     {
00187     case GDK_Page_Up:
00188         BR_LOGPRINTF("jumping to the next page");
00189         if (mozilla_scrollable(pageUp_t, GTK_MOZ_EMBED(mozEmbed)) == FALSE)
00190         {
00191             if (mozilla_previous_page(GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00192             {
00193                 BR_LOGPRINTF("BUSY ON");
00194                 erbusy_blink();
00195             }
00196             else
00197             {
00198                 BR_LOGPRINTF("mozilla_previous_page returend FALSE");
00199                 erbusy_off();
00200             }
00201         }
00202         else
00203         {
00204             if (mozilla_scroll(-1, GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00205             {
00206               offset = mozilla_determine_page_offset(GTK_MOZ_EMBED(mozEmbed));
00207               pagebar_set_offset(offset);
00208               pagebar_redraw();
00209               display_update_request_screen_refresh(MOZEMBED_UPDATE_LEVEL, NULL);
00210             }
00211         }
00212         // return TRUE => stop event handling 
00213         returnValue = 1;
00214         break;
00215 
00216     case GDK_F1:
00217         BR_LOGPRINTF("PAGETURN_FORWARD LONG");
00218 
00219         pagecount = reader->pageStatus->pageCount;
00220         currentpage = reader->pageStatus->currentPage;
00221         newpage = ((currentpage + 5) <= pagecount) ? (currentpage + 5) : pagecount;
00222 
00223                 printf("NEWPAGE: %d (%d, %d)\n", newpage, currentpage, pagecount);
00224                 
00225         browser_pagebar_page_selected(newpage, gEreader);
00226 
00227         // return TRUE => stop event handling 
00228         returnValue = 1;
00229         break;
00230 
00231     case GDK_Page_Down:
00232         BR_LOGPRINTF("jumping to the previous page");
00233         if (mozilla_scrollable(pageDown_t, GTK_MOZ_EMBED(mozEmbed)) == FALSE)
00234         {
00235             if (mozilla_next_page(GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00236             {
00237                 BR_LOGPRINTF("BUSY ON");
00238                 erbusy_blink();
00239             }
00240             else
00241             {
00242                 BR_LOGPRINTF("mozilla_next_page returend FALSE");
00243                 erbusy_off();
00244             }
00245         }
00246         else
00247         {
00248             if (mozilla_scroll(1, GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00249             {
00250               offset = mozilla_determine_page_offset(GTK_MOZ_EMBED(mozEmbed));
00251               pagebar_set_offset(offset);
00252               pagebar_redraw();
00253               display_update_request_screen_refresh(MOZEMBED_UPDATE_LEVEL, NULL);
00254             }
00255         }
00256 
00257         // return TRUE => stop event handling 
00258         returnValue = 1;
00259         break;
00260 
00261     case GDK_F2:
00262         BR_LOGPRINTF("PAGETURN_BACK LONG");
00263 
00264         pagecount = reader->pageStatus->pageCount;
00265         currentpage = reader->pageStatus->currentPage;
00266         newpage = ((currentpage - 5) < 1) ? (1) : (currentpage - 5);
00267 
00268         printf("NEWPAGE: %d (%d, %d)\n", newpage, currentpage, pagecount);
00269 
00270         // erbusy_blink() is handled in this routine
00271         browser_pagebar_page_selected(newpage, gEreader);
00272 
00273         // return TRUE => stop event handling 
00274         returnValue = 1;
00275         break;
00276 
00277     case GDK_Up:
00278         BR_LOGPRINTF("jumping to the previous link");
00279 
00280         if (mozilla_previous_link(GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00281         {
00282             // use non-flashy display update
00283             display_update_request_screen_refresh(MOZEMBED_UPDATE_LEVEL, (gpointer) DM_QUALITY_TYPING);
00284         }
00285         else
00286         {
00287             BR_LOGPRINTF("mozilla_previous_link returend FALSE");
00288             erbusy_off();
00289         }
00290         // return TRUE => stop event handling 
00291         returnValue = 1;
00292         break;
00293 
00294     case GDK_Down:
00295         BR_LOGPRINTF("jumping to the next link");
00296 
00297         if (mozilla_next_link(GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00298         {
00299             // use non-flashy display update
00300             display_update_request_screen_refresh(MOZEMBED_UPDATE_LEVEL, (gpointer) DM_QUALITY_TYPING);
00301         }
00302         else
00303         {
00304             BR_LOGPRINTF("mozilla_next_link returend FALSE");
00305             erbusy_off();
00306         }
00307 
00308         // return TRUE => stop event handling 
00309         returnValue = 1;
00310         break;
00311 
00312     case GDK_F5:
00313       BR_LOGPRINTF("up key (F5) pressed... history.go(-1)");
00314         if (mozilla_back(GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00315         {
00316             BR_LOGPRINTF("BUSY ON");
00317             erbusy_blink();
00318         }
00319         else
00320         {
00321             BR_ERRORPRINTF("mozilla_back returend FALSE (we are home), exit the app");
00322             erbusy_blink();
00323             browser_quit();
00324             gtk_main_quit();
00325         }
00326         // return TRUE => stop event handling 
00327         returnValue = 1;
00328         break;
00329 
00330     case GDK_F6:
00331         BR_LOGPRINTF("long confirm key (F6) pressed... goto ALT page");
00332         if (mozilla_alt_page(GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00333         {
00334           BR_LOGPRINTF("BUSY ON");
00335           erbusy_blink();
00336         }
00337         else
00338         {
00339           BR_LOGPRINTF("mozilla_back returend FALSE");
00340           erbusy_off();
00341         }
00342         // return TRUE => stop event handling 
00343         returnValue = 1;
00344         break;
00345 
00346       case GDK_Home:
00347         BR_LOGPRINTF("long up key (Home) pressed... goto INDEX page");
00348         if (mozilla_overview_page(GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00349         {
00350 //          BR_LOGPRINTF("BUSY ON");
00351 //          erbusy_blink();
00352         }
00353         else
00354         {
00355           BR_LOGPRINTF("mozilla_overview_page returend FALSE");
00356           erbusy_off();
00357         }
00358         // return TRUE => stop event handling 
00359         returnValue = 1;
00360         break;
00361 
00362     case GDK_Return:
00363         BR_LOGPRINTF("handle the current link");
00364         if (mozilla_handle_link(GTK_MOZ_EMBED(mozEmbed)) == TRUE)
00365         {
00366             BR_LOGPRINTF("BUSY ON");
00367             erbusy_blink();
00368         }
00369         break;
00370 //
00371 // Highlight/selection is enabled/disabled in selection.h in the browser code 
00372 //    - should be added to the toolbar.cpp file late one  
00373 //
00374 #ifdef SELECTION_ENABLED
00375     case GDK_p:
00376         char    filename[256];
00377 
00378         //Used for debugging the highligth feature  
00379         sprintf(filename, "/home/ann/temp_files/selection.html");
00380         BR_LOGPRINTF("p key pressed => mozilla_save page in %s!!!", filename);
00381         if (mozilla_save(GTK_MOZ_EMBED(mozEmbed), filename, 1) == FALSE)
00382         {
00383             BR_LOGPRINTF("mozilla_save returned FALSE");
00384         }
00385         break;
00386 
00387     case GDK_i:
00388         BR_LOGPRINTF("identify_selection key pressed...");
00389         selection_identify_and_store_selection(GTK_MOZ_EMBED(mozEmbed));
00390         break;
00391 
00392     case GDK_r:
00393         BR_LOGPRINTF("r pressed ==> clear selections");
00394         selection_clear_current_page_selections(GTK_MOZ_EMBED(mozEmbed));
00395         break;
00396 #endif //SELECTION_ENABLED
00397 
00398 //
00399 // Find was added to try out the language support 
00400 //    - only tried on PC environment (no display update for dialog yet) 
00401 //    - the setup application should be used as an example for the language support
00402 //    - only searches within the currenly loaded XHTML page
00403 //    - should be added to the toolbar.cpp file late one  
00404 //
00405 #ifdef FIND_DIALOG_ENABLED
00406     case GDK_f:
00407         BR_LOGPRINTF("f pressed => INVOKE FIND DIALOG");
00408         browser_find_dialog_create(reader);
00409         break;
00410 #endif //FIND_DIALOG_ENABLED
00411 
00412     default:
00413         // Unhandled key pressed
00414         erbusy_off();
00415         break;
00416     
00417     } // switch
00418 
00419     return returnValue;
00420 }

Here is the call graph for this function:


Variable Documentation

Ereader* gEreader [static]

Definition at line 54 of file main.cpp.


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