scribble/inc/ScribbleIPC.h File Reference

scribble - IPC communication More...

#include <gtk/gtk.h>
#include "ScribbleDefine.h"
#include "ScribbleUtils.h"

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

Go to the source code of this file.

Defines

#define SCRIB_SERVER_BUFFER_SIZE   (1024)

Enumerations

enum  OPERATION_MODE {
  MODE_DRAW = 0, MODE_SELSIZE = 1, MODE_SELCOLOR = 2, MODE_ERASE = 3,
  MODE_DELPAGE = 4, MODE_INVALID = 5
}

Functions

gboolean installIpcServer (PScribbleUICtx pScribbleUICtx)
void stopIpcServer (void)
void pagebar_init ()
void pagebar_goto_page (int page)
void pagebar_set_pagecount (int count)
void pagebar_redraw ()
void toolbar_init (void)
void toolbar_key_selected (int iconID, int iconState, PScribbleUICtx pScribbleUICtx)
OPERATION_MODE getOperationMode ()
void setOperationMode (OPERATION_MODE iOpMode)
HW_COLOR getPenColor ()
void setPenColor (HW_COLOR iHwColor)
PEN_SIZE getPenSize ()
void setPenSize (PEN_SIZE iPenSize)
gboolean toolbar_is_waitconfirmdel ()
void toolbar_confirm_delpage ()
gboolean toolbar_is_erasing ()
gboolean toolbar_is_drawing ()
void toolbar_clearall ()
void toolbar_firstinit (int iTotalPage)
void toolbar_reinit (int iTotalPage)


Detailed Description

scribble - IPC communication

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Author:
Jian Shen
<File description>="">

Definition in file ScribbleIPC.h.


Define Documentation

#define SCRIB_SERVER_BUFFER_SIZE   (1024)

Definition at line 40 of file ScribbleIPC.h.


Enumeration Type Documentation

Enumerator:
MODE_DRAW 
MODE_SELSIZE 
MODE_SELCOLOR 
MODE_ERASE 
MODE_DELPAGE 
MODE_INVALID 

Definition at line 100 of file ScribbleIPC.h.

00100              {
00101     MODE_DRAW=0,  
00102     MODE_SELSIZE=1,//when selecting the pen size
00103     MODE_SELCOLOR=2,//when selecting the color
00104     MODE_ERASE=3,
00105     MODE_DELPAGE=4,//when wanna deleting pages
00106     MODE_INVALID=5,//initially,invalid
00107 }OPERATION_MODE;


Function Documentation

OPERATION_MODE getOperationMode (  ) 

Definition at line 56 of file toolbar.c.

00057 {
00058     return s_OperationMode;
00059 }

HW_COLOR getPenColor (  ) 

Definition at line 68 of file toolbar.c.

00069 {
00070     return s_PenColor;
00071 }

PEN_SIZE getPenSize (  ) 

Definition at line 80 of file toolbar.c.

00081 {
00082     return m_PenSize;
00083 }

gboolean installIpcServer ( PScribbleUICtx  pScribbleUICtx  ) 

Start listening to IPC requests

Parameters:
PScribbleUICtx scribble ui context
Returns:
-

Definition at line 88 of file IPCServer.c.

00089 {
00090     int     iRet = 0;
00091     int     fd = -1;
00092 
00093     SB_IPCPRINTF("__start__\n");
00094     iRet = erIpcOpenServerChannel(ER_SCRIBBLE_CHANNEL,
00095                                   &srvChannel);
00096     if (iRet != 0)
00097     {
00098         SB_ERRORPRINTF("erIpcOpenServerChannel returned %d\n", iRet);
00099         return iRet;
00100     }
00101     fd = erIpcGetServerFd(srvChannel);
00102     // gtk specific mechanism to monitor input file descriptor.
00103     srvInputTag = gdk_input_add(fd, GDK_INPUT_READ, 
00104                                 ipcMessageReceived, (gpointer) pScribbleUICtx);
00105     SB_IPCPRINTF("__finish__\n");
00106     return iRet;
00107 }

Here is the call graph for this function:

void pagebar_goto_page ( int  page  ) 

Request from scribble to goto page

Parameters:
page - page to go to
Returns:
-

Definition at line 55 of file pagebar.c.

00056 {
00057     SB_PAGEBARPRINTF("entry %d\n", page);
00058     pbSetCurrentPage(erPagebarChannel, ER_SCRIBBLE_UA_ID, page);
00059 }

void pagebar_init (  ) 

Open communication channel with pageBar deamon counts on the fact that pageBar is running

Returns:
void

Definition at line 41 of file pagebar.c.

00042 {
00043     int iRet=-1;
00044     SB_PAGEBARPRINTF("entry\n");
00045     iRet=erIpcStartClient(ER_PAGEBAR_CHANNEL, &erPagebarChannel);
00046     if (iRet != 0)
00047     {
00048         SB_ERRORPRINTF("erIpcStartClient returned %d\n", iRet);
00049         return;
00050     }
00051     pbReset(erPagebarChannel, ER_SCRIBBLE_UA_ID);
00052 }

void pagebar_redraw (  ) 

Request from contentLister to redraw pagebar

Parameters:
- 
Returns:
-

Definition at line 69 of file pagebar.c.

00070 {
00071     SB_PAGEBARPRINTF("redraw\n");
00072     pbRedraw(erPagebarChannel, ER_SCRIBBLE_UA_ID);
00073 }

void pagebar_set_pagecount ( int  count  ) 

Request from browser to set number of pages

Parameters:
count - number of pages in current view
Returns:
-

Definition at line 62 of file pagebar.c.

00063 {
00064     SB_PAGEBARPRINTF("entry %d\n", count);
00065     pbSetPageCount(erPagebarChannel, ER_SCRIBBLE_UA_ID, count);
00066 }

void setOperationMode ( OPERATION_MODE  iOpMode  ) 

Definition at line 60 of file toolbar.c.

00061 {
00062     s_OperationMode=iOpMode;
00063 }

void setPenColor ( HW_COLOR  iHwColor  ) 

Definition at line 73 of file toolbar.c.

00074 {
00075     s_PenColor=iHwColor;
00076 }

void setPenSize ( PEN_SIZE  iPenSize  ) 

Definition at line 84 of file toolbar.c.

00085 {
00086     m_PenSize=iPenSize;
00087 }

void stopIpcServer ( void   ) 

Stop listening to IPC requests

Returns:
-

Definition at line 110 of file IPCServer.c.

00111 {
00112     int fd = erIpcGetServerFd(srvChannel);
00113 
00114     SB_IPCPRINTF("__start__\n");
00115     gdk_input_remove(srvInputTag);
00116     close(fd);
00117     SB_IPCPRINTF("__finish__\n");
00118 }

void toolbar_clearall (  ) 

Definition at line 342 of file toolbar.c.

00343 {
00344     tbClearIconSet(toolbarChannel, ER_SCRIBBLE_UA_ID);
00345 }

void toolbar_confirm_delpage (  ) 

Definition at line 226 of file toolbar.c.

00227 {
00228     ispagedel_confirmed=TRUE;
00229 }

void toolbar_firstinit ( int  iTotalPage  ) 

Definition at line 348 of file toolbar.c.

00349 {
00350     setOperationMode(MODE_DRAW);
00351     drawIconsByMode(iTotalPage);
00352 }

Here is the call graph for this function:

void toolbar_init ( void   ) 

Init toolbar (open communication channel and enable/set the correct icons)

Returns:
void

Definition at line 365 of file toolbar.c.

00366 {
00367     int     returnValue;
00368 
00369     SB_IPCPRINTF("\n\n\nentry,ER_TOOLBAR_CHANNEL=%d\n\n",
00370                  ER_TOOLBAR_CHANNEL);
00371     toolbarChannel=NULL;
00372     // create/init channel to communicate with the toolbar service
00373     returnValue = erIpcStartClient(ER_TOOLBAR_CHANNEL, &toolbarChannel);
00374     if (returnValue != 0)
00375     {
00376         SB_ERRORPRINTF("erIpcStartClient returned %d\n", returnValue);
00377         return;
00378     }
00379     // tell toolbar which icons set to display
00380     tbSelectIconSet(toolbarChannel, ER_SCRIBBLE_UA_ID);
00381 }

gboolean toolbar_is_drawing (  ) 

Definition at line 238 of file toolbar.c.

00239 {
00240     return(    MODE_DRAW     ==s_OperationMode 
00241             || MODE_SELSIZE  ==s_OperationMode
00242             || MODE_SELCOLOR ==s_OperationMode);
00243 }

gboolean toolbar_is_erasing (  ) 

Definition at line 232 of file toolbar.c.

00233 {
00234     return (MODE_ERASE== s_OperationMode);
00235 }

gboolean toolbar_is_waitconfirmdel (  ) 

Definition at line 219 of file toolbar.c.

00220 {
00221     return ( MODE_DELPAGE==s_OperationMode );
00222 }

void toolbar_key_selected ( int  iconID,
int  iconState,
PScribbleUICtx  pScribbleUICtx 
)

A key is selected on the toolbar

Parameters:
command the command associated with the selected key
PScribbleUICtx scribble ui context
Returns:
-

Definition at line 383 of file toolbar.c.

00384 {
00385     if( iconState_grey==iconState )
00386     {
00387         return;//donothing.
00388     }
00389     
00390     SB_IPCPRINTF("\n====iconID=%d[mode=%d,pensize=%d,color=%d]\n",
00391                  iconID,getOperationMode(),getPenSize(),getPenColor());
00392   
00393     gboolean bNeedFlushWithFullQlt=FALSE;
00394     //need full update when return from erase mode.
00395     if( getOperationMode()== MODE_ERASE)
00396     {
00397         //every erase stroke ,we do it, so it's useless
00398         //core_redrawBgAndStrks(pScribbleUICtx);
00399         bNeedFlushWithFullQlt=TRUE;
00400     }           
00401     //we should add deal to pageup/pagedown
00402     switch (iconID)
00403     {
00404         case iconID_pen:
00405             //we switch by whether or not user is drawing
00406             if( !toolbar_is_drawing() ) 
00407             {
00408                 setOperationMode(MODE_DRAW);
00409             }
00410             else 
00411             {
00412                 setOperationMode(MODE_INVALID);
00413             } 
00414             break;
00415         case iconID_pen1pixel:
00416         case iconID_pen3pixel:
00417         case iconID_pen5pixel:
00418         case iconID_pen7pixel:
00419             //enter select mode
00420             setOperationMode(MODE_SELSIZE);
00421             break;
00422         case iconID_pen1pixelLow:
00423         case iconID_pen3pixelLow:
00424         case iconID_pen5pixelLow:
00425         case iconID_pen7pixelLow:
00426             //confirm the select                
00427             setPenSize(getPenSizefromIcon(iconID));
00428             setOperationMode(MODE_DRAW);
00429             break;
00430         case iconID_penwhite://WHITE
00431         case iconID_penlightgrey://LIGHT_GRAY
00432         case iconID_pendarkgrey://DARK_GRAY
00433         case iconID_penblack://BLACK
00434             //enter select mode
00435             setOperationMode(MODE_SELCOLOR);
00436             break;
00437         case iconID_penwhiteLow://WHITE
00438         case iconID_penlightgreyLow://LIGHT_GRAY
00439         case iconID_pendarkgreyLow://DARK_GRAY
00440         case iconID_penblackLow://BLACK
00441             //confirm the select                
00442             setPenColor(getPenColorfromIcon(iconID));
00443             setOperationMode(MODE_DRAW);
00444             break;
00445         case iconID_eraseline:
00446             if( MODE_ERASE==getOperationMode())
00447             {
00448                 setOperationMode(MODE_DRAW);
00449             }
00450             else
00451             {
00452                 setOperationMode(MODE_ERASE);
00453             }             
00454             break;
00455         case iconID_trashcan://delete page
00456             if(MODE_DELPAGE==getOperationMode())
00457             {                
00458                 setOperationMode(MODE_DRAW);
00459                 if(ispagedel_confirmed)
00460                 {
00461                             //delete page
00462                     delOnepage(pScribbleUICtx);   
00463                     ispagedel_confirmed=FALSE;                    
00464                     return;//tool bar will be updated when jumping
00465                 }  
00466                 ispagedel_confirmed=FALSE;                  
00467             }
00468             else
00469             {
00470                 SB_IPCPRINTF("enter MODE_DELPAGE\n");
00471                 setOperationMode(MODE_DELPAGE);
00472                 ispagedel_confirmed=FALSE;
00473             }
00474             break;
00475         case iconID_npage:
00476             addOnepage(pScribbleUICtx);
00477             return;//tool bar will be updated when jumping
00478         default:
00479             SB_IPCPRINTF("Unknown iconID [%d]\n", iconID);
00480             return;
00481     }
00482     
00483     drawIconsByMode(getTotalPage(&pScribbleUICtx->fileManager));
00484     //flush the pixmap to gdk_buffer,but now every stroke is flush,so it's useless.
00485     //flushPixMap(pScribbleUICtx);
00486     if(bNeedFlushWithFullQlt)
00487     {
00488         display_update_request_screen_refresh
00489                 (MAIN_WINDOW_EXPOSE_LEVEL,(gpointer)dmQFull);
00490     }
00491     else
00492     {
00493         display_update_request_screen_refresh
00494                 (MAIN_WINDOW_EXPOSE_LEVEL,(gpointer)dmQTyping);
00495     }
00496     SB_IPCPRINTF("\n===end===[mode=%d,pensize=%d,color=%d]\n",
00497                  getOperationMode(),getPenSize(),getPenColor());
00498     return;
00499 }

Here is the call graph for this function:

void toolbar_reinit ( int  iTotalPage  ) 

Definition at line 355 of file toolbar.c.

00356 {
00357     //change the current mode only if current is mode_draw or erase.
00358     if( MODE_DELPAGE==getOperationMode() )
00359     {
00360         setOperationMode(MODE_DRAW);
00361     }
00362     drawIconsByMode(iTotalPage);
00363 }

Here is the call graph for this function:


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