#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <pthread.h>
#include <stdlib.h>
#include "npapi.h"
#include "npupp.h"
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/X.h>
#include <semaphore.h>
#include <errno.h>
Go to the source code of this file.
Data Structures | |
struct | _PluginInstance |
struct | _ThreadParam |
Defines | |
#define | MASK_MPLAYER 1 |
#define | MASK_RIOCLIENT 2 |
#define | MASK_TGIF 4 |
#define | MASK_INDEX 8 |
#define | MAX_PLUGINS 16 |
#define | PLUGINS_MASK ( ( 1 << 16 ) - 1 ) |
#define | PLUGIN_NAME "RIO Browser Plug-in version "VERSION |
#define | PLUGIN_DESCRIPTION |
Typedefs | |
typedef struct _PluginInstance | PluginInstance |
typedef struct _ThreadParam | ThreadParam |
Functions | |
void | ChangeSlide (void *param) |
void * | listenerThread (void *param) |
static int | startListenerThread (NPP instance) |
static void | startRioClient (PluginInstance *this, int port) |
static int | isComplete (void) |
char * | NPP_GetMIMEDescription (void) |
NPError | NPP_GetValue (NPP instance, NPPVariable variable, void *value) |
NPError | NPP_Initialize (void) |
void | NPP_Shutdown (void) |
NPError | NPP_New (NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved) |
NPError | NPP_Destroy (NPP instance, NPSavedData **save) |
NPError | NPP_SetWindow (NPP instance, NPWindow *window) |
NPError | NPP_NewStream (NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype) |
int32 | NPP_WriteReady (NPP instance, NPStream *stream) |
int32 | NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer) |
NPError | NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason) |
void | NPP_StreamAsFile (NPP instance, NPStream *stream, const char *fname) |
void | NPP_Print (NPP instance, NPPrint *printInfo) |
void | NPP_URLNotify (NPP instance, const char *url, NPReason reason, void *notifyData) |
Variables | |
int | mID = 0 |
int | rID = 0 |
int | tID = 0 |
int | iID |
int | MaskComplete = 0 |
int | CurMask |
char | server [128] |
char | media [254] |
char | SlideUrl [255] |
sem_t | ChangeSlideSemaphore |
int | UseChangeSlide |
int32 | STREAMBUFSIZE = 0X0FFFFFFF |
#define MASK_INDEX 8 |
Definition at line 25 of file RioBrowserPlugin.c.
#define MASK_MPLAYER 1 |
Definition at line 22 of file RioBrowserPlugin.c.
#define MASK_RIOCLIENT 2 |
Definition at line 23 of file RioBrowserPlugin.c.
#define MASK_TGIF 4 |
Definition at line 24 of file RioBrowserPlugin.c.
#define MAX_PLUGINS 16 |
Definition at line 27 of file RioBrowserPlugin.c.
#define PLUGIN_DESCRIPTION |
"This plug-in allows RIO client to be embeded "\ "into browser frames."
Definition at line 325 of file RioBrowserPlugin.c.
#define PLUGIN_NAME "RIO Browser Plug-in version "VERSION |
Definition at line 324 of file RioBrowserPlugin.c.
#define PLUGINS_MASK ( ( 1 << 16 ) - 1 ) |
Definition at line 28 of file RioBrowserPlugin.c.
typedef struct _PluginInstance PluginInstance |
typedef struct _ThreadParam ThreadParam |
void ChangeSlide | ( | void * | param | ) |
Definition at line 57 of file RioBrowserPlugin.c.
00058 { 00059 NPP instance; 00060 NPError Error; 00061 int error; 00062 00063 #ifdef RIO_DEBUG1 00064 fprintf( stderr, "[RioBrowserPlugin - ChangeSlide] Start\n" ); 00065 #endif 00066 00067 instance = ( NPP ) param; 00068 00069 // Muda a transparencia. 00070 Error = NPN_GetURL( instance, SlideUrl, "slide" ); 00071 00072 if( Error != NPERR_NO_ERROR ) 00073 { 00074 // Imprime a mensagem informando sobre as transparencias. 00075 NPN_Status( instance, "Error loading slide." ); 00076 } 00077 00078 // Librea a thread listenerThread bloqueada em ChangeSlideSemaphore, que 00079 // esta esperando pela mudanca da transparencia 00080 if( sem_post( &ChangeSlideSemaphore ) < 0 ) 00081 { 00082 error = errno; 00083 fprintf( stderr, "[cederj]: sem_post failed with error %d (%s)\n", 00084 error, strerror( error ) ); 00085 } 00086 00087 #ifdef RIO_DEBUG1 00088 fprintf( stderr, "[RioBrowserPlugin - ChangeSlide] Finish\n" ); 00089 #endif 00090 }
static int isComplete | ( | void | ) | [static] |
Definition at line 278 of file RioBrowserPlugin.c.
00279 { 00280 int mask; 00281 int result; 00282 00283 #ifdef RIO_DEBUG1 00284 fprintf( stderr, "[RioBrowserPlugin - isComplete] Start\n" ); 00285 #endif 00286 00287 result = 0; 00288 if( CurMask == MaskComplete ) 00289 { 00290 mask = 0; 00291 if( ( CurMask & MASK_MPLAYER ) != 0 && mID != 0 ) 00292 mask |= MASK_MPLAYER; 00293 if( ( CurMask & MASK_RIOCLIENT ) != 0 && rID != 0 ) 00294 mask |= MASK_RIOCLIENT; 00295 if( ( CurMask & MASK_TGIF ) != 0 && tID != 0 ) 00296 mask |= MASK_TGIF; 00297 if( ( CurMask & MASK_INDEX ) != 0 && iID != 0 ) 00298 mask |= MASK_INDEX; 00299 00300 if( mask == MaskComplete ) 00301 result = 1; 00302 } 00303 00304 #ifdef RIO_DEBUG1 00305 fprintf( stderr, "[RioBrowserPlugin - isComplete] Finish\n" ); 00306 #endif 00307 00308 return( result ); 00309 }
void* listenerThread | ( | void * | param | ) |
Definition at line 92 of file RioBrowserPlugin.c.
00093 { 00094 int END; 00095 int byread; 00096 int error; 00097 char pkt[ 255 ]; 00098 ThreadParam *p; 00099 NPError Error; 00100 00101 #ifdef RIO_DEBUG1 00102 fprintf( stderr, "[RioBrowserPlugin - listenerThread] Start\n" ); 00103 #endif 00104 00105 END = 0; 00106 p = ( ThreadParam * ) param; 00107 do 00108 { 00109 byread = recvfrom( p->soc, pkt, 254, 0, NULL, 0 ); 00110 if( byread > 0 ) 00111 { 00112 if( strncmp( pkt, "quit", 4 ) == 0 ) 00113 END = 1; 00114 if( strncmp( pkt, "chgu", 4 ) == 0 ) 00115 { 00116 if( UseChangeSlide ) 00117 { 00118 #ifdef RIO_DEBUG2 00119 fprintf( stderr, "listenerThread: Usando a funcao " ); 00120 fprintf( stderr, "NPN_PluginThreadAsyncCall\n" ); 00121 #endif 00122 // Copia a Url para a estrutura FileUrl. 00123 strcpy( SlideUrl, &pkt[ 5 ] ); 00124 // Chama assincronamente a funcao para mudar a transparencia 00125 // (isso e necessario no Firefox 3.0 em diante, pois somente 00126 // a thread principal pode usar as funcoes do browser a 00127 // partir desta versao. 00128 NPN_PluginThreadAsyncCall( p->instance, ChangeSlide, 00129 ( void * ) p->instance ); 00130 // Espera que a transparencia seja mudada pela thread 00131 // principal do browser. 00132 if( sem_wait( &ChangeSlideSemaphore ) < 0 ) 00133 { 00134 error = errno; 00135 fprintf( stderr, "[cederj]: sem_wait failed with " ); 00136 fprintf( stderr, "error %d (%s)\n", error, 00137 strerror( error ) ); 00138 } 00139 } 00140 else 00141 { 00142 #ifdef RIO_DEBUG2 00143 fprintf( stderr, "listenerThread: Usando a funcao " ); 00144 fprintf( stderr, "NPN_GetURL como antes\n" ); 00145 #endif 00146 Error = NPN_GetURL( p->instance, &pkt[ 5 ], "slide" ); 00147 if( Error != NPERR_NO_ERROR ) 00148 { 00149 // Imprime a mensagem informando sobre as 00150 // transparencias. 00151 NPN_Status( p->instance, 00152 "Error loading slide. Upgrade your browser" ); 00153 } 00154 } 00155 } 00156 } 00157 } 00158 while( !END ); 00159 00160 NPN_MemFree( param ); 00161 00162 #ifdef RIO_DEBUG1 00163 fprintf( stderr, "[RioBrowserPlugin - listenerThread] Finish\n" ); 00164 #endif 00165 00166 return( NULL ); 00167 }
NPError NPP_Destroy | ( | NPP | instance, | |
NPSavedData ** | save | |||
) |
Definition at line 545 of file RioBrowserPlugin.c.
00546 { 00547 NPError result; 00548 PluginInstance *This; 00549 00550 #ifdef RIO_DEBUG1 00551 fprintf( stderr, "[RioBrowserPlugin - NPP_Destroy] Start\n" ); 00552 #endif 00553 00554 result = NPERR_INVALID_INSTANCE_ERROR; 00555 if( instance != NULL ) 00556 { 00557 This = ( PluginInstance* ) instance->pdata; 00558 if( This != NULL ) 00559 { 00560 if( This->pid ) 00561 kill( This->pid, 15 ); 00562 NPN_MemFree( instance->pdata ); 00563 instance->pdata = NULL; 00564 } 00565 result = NPERR_NO_ERROR; 00566 } 00567 00568 #ifdef RIO_DEBUG1 00569 fprintf( stderr, "[RioBrowserPlugin - NPP_Destroy] Finish\n" ); 00570 #endif 00571 00572 return result; 00573 }
Definition at line 725 of file RioBrowserPlugin.c.
00726 { 00727 PluginInstance *This; 00728 00729 #ifdef RIO_DEBUG1 00730 fprintf( stderr, "[RioBrowserPlugin - NPP_DestroyStream] Start\n" ); 00731 #endif 00732 00733 if( instance == NULL ) 00734 { 00735 00736 #ifdef RIO_DEBUG1 00737 fprintf( stderr, "[RioBrowserPlugin - NPP_DestroyStream] Finish1\n" ); 00738 #endif 00739 00740 return NPERR_INVALID_INSTANCE_ERROR; 00741 } 00742 This = ( PluginInstance * )instance->pdata; 00743 00744 #ifdef RIO_DEBUG1 00745 fprintf( stderr, "[RioBrowserPlugin - NPP_DestroyStream] Finish2\n" ); 00746 #endif 00747 00748 return NPERR_NO_ERROR; 00749 }
char* NPP_GetMIMEDescription | ( | void | ) |
Definition at line 313 of file RioBrowserPlugin.c.
NPError NPP_GetValue | ( | NPP | instance, | |
NPPVariable | variable, | |||
void * | value | |||
) |
Definition at line 328 of file RioBrowserPlugin.c.
00329 { 00330 NPError err = NPERR_NO_ERROR; 00331 00332 #ifdef RIO_DEBUG1 00333 fprintf( stderr, "[RioBrowserPlugin - NPP_GetValue] Start\n" ); 00334 #endif 00335 00336 #ifdef RIO_DEBUG2 00337 fprintf( stderr, "NPP_GetValue : inicio da funcao. instance = %p ", 00338 instance ); 00339 fprintf( stderr, "variable = %d\n", variable ); 00340 #endif 00341 00342 if( variable == NPPVpluginNameString ) 00343 *( ( char ** ) value ) = PLUGIN_NAME; 00344 else if( variable == NPPVpluginDescriptionString ) 00345 *( ( char ** ) value ) = PLUGIN_DESCRIPTION; 00346 else 00347 err = NPERR_GENERIC_ERROR; 00348 00349 #ifdef RIO_DEBUG2 00350 fprintf( stderr, "NPP_GetValue : fim da funcao. err = %d\n", err ); 00351 #endif 00352 00353 #ifdef RIO_DEBUG1 00354 fprintf( stderr, "[RioBrowserPlugin - NPP_GetValue] Finish\n" ); 00355 #endif 00356 00357 return err; 00358 }
NPError NPP_Initialize | ( | void | ) |
Definition at line 368 of file RioBrowserPlugin.c.
00369 { 00370 int plugin_major, plugin_minor, netscape_major, netscape_minor; 00371 int error; 00372 00373 #ifdef RIO_DEBUG1 00374 fprintf( stderr, "[RioBrowserPlugin - NPP_Initialize] Start\n" ); 00375 #endif 00376 00377 // Obtem as versoes do plugin e do browser. 00378 00379 NPN_Version( &plugin_major, &plugin_minor, &netscape_major, 00380 &netscape_minor ); 00381 00382 #ifdef RIO_DEBUG2 00383 fprintf( stderr, "NPP_Initialize: NPP_New plugin_major = %d\n", 00384 plugin_major ); 00385 fprintf( stderr, "NPP_Initialize: NPP_New plugin_minor = %d\n", 00386 plugin_minor ); 00387 fprintf( stderr, "NPP_Initialize: NPP_New netscape_major = %d\n", 00388 netscape_major ); 00389 fprintf( stderr, "NPP_Initialize: NPP_New netscape_minor = %d\n", 00390 netscape_minor ); 00391 #endif 00392 00393 // Cria o semaforo, se a versao for a adequada do plugin e do browser. 00394 00395 if( netscape_minor < NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL ) 00396 { 00397 #ifdef RIO_DEBUG2 00398 fprintf( stderr, "NPP_Initialize: NPN_PluginThreadAsyncCall nao " ); 00399 fprintf( stderr, "disponivel. Usando a implementacao original do " ); 00400 fprintf( stderr, "plugin!\n"); 00401 #endif 00402 UseChangeSlide = 0; 00403 } 00404 else 00405 { 00406 #ifdef RIO_DEBUG2 00407 fprintf( stderr, "NPP_Initialize: NPN_PluginThreadAsyncCall " ); 00408 fprintf( stderr, "disponivel. Usando a nova implementacao!\n" ); 00409 #endif 00410 // Cria o semaforo ChangeSlideSemaphore. O semaforo e inicializado com 00411 // 0 porque a thread startListenerThread deve ser bloqueada ao executar 00412 // sem_wait, pois precisa esperar que a transparencia seja mudada. 00413 if( sem_init( &ChangeSlideSemaphore, 0, 0 ) < 0 ) 00414 { 00415 error = errno; 00416 fprintf( stderr, "[cederj]: sem_init failed with error %d (%s) ", 00417 error, strerror( error ) ); 00418 fprintf( stderr, ". Using previous implementation!\n" ); 00419 UseChangeSlide = 0; 00420 } 00421 else 00422 { 00423 #ifdef RIO_DEBUG2 00424 fprintf( stderr, "NPP_Initialize: Semaforo criado com sucesso!\n" ); 00425 #endif 00426 UseChangeSlide = 1; 00427 } 00428 } 00429 00430 #ifdef RIO_DEBUG1 00431 fprintf( stderr, "[RioBrowserPlugin - NPP_Initialize] Finish\n" ); 00432 #endif 00433 00434 return NPERR_NO_ERROR; 00435 }
NPError NPP_New | ( | NPMIMEType | pluginType, | |
NPP | instance, | |||
uint16 | mode, | |||
int16 | argc, | |||
char * | argn[], | |||
char * | argv[], | |||
NPSavedData * | saved | |||
) |
Definition at line 486 of file RioBrowserPlugin.c.
00488 { 00489 int i, mask; 00490 NPError result; 00491 PluginInstance *This; 00492 00493 #ifdef RIO_DEBUG1 00494 fprintf( stderr, "[RioBrowserPlugin - NPP_New] Start\n" ); 00495 #endif 00496 00497 result = NPERR_INVALID_INSTANCE_ERROR; 00498 if( instance != NULL ) 00499 { 00500 instance->pdata = NPN_MemAlloc( sizeof( PluginInstance ) ); 00501 This = ( PluginInstance * ) instance->pdata; 00502 if( This != NULL ) 00503 { 00504 This->window = 0; 00505 This->fMode = mode; 00506 This->mask = 0; 00507 This->pid = 0; 00508 for( i = 0; i < argc; i++ ) 00509 { 00510 if( strcasecmp( argn[ i ], "server" ) == 0 ) 00511 strcpy( server, argv[ i ] ); 00512 if( strcasecmp( argn[ i ], "file" ) == 0 ) 00513 strcpy( media, argv[ i ] ); 00514 if( strcasecmp( argn[ i ], "mask" ) == 0 ) 00515 { 00516 mask = atoi( argv[ i ] ); 00517 This->mask = ( mask & PLUGINS_MASK ); 00518 if( MaskComplete == 0 ) 00519 MaskComplete = ( mask >> MAX_PLUGINS ); 00520 00521 /* Sanity Check */ 00522 if( ( mask >> MAX_PLUGINS ) == MaskComplete ) 00523 { 00524 CurMask = CurMask | ( mask & PLUGINS_MASK ); 00525 /* All plugins are loaded */ 00526 } 00527 } 00528 } 00529 result = NPERR_NO_ERROR; 00530 } 00531 else 00532 { 00533 result = NPERR_OUT_OF_MEMORY_ERROR; 00534 } 00535 } 00536 00537 #ifdef RIO_DEBUG1 00538 fprintf( stderr, "[RioBrowserPlugin - NPP_New] Finish\n" ); 00539 #endif 00540 00541 return result; 00542 }
NPError NPP_NewStream | ( | NPP | instance, | |
NPMIMEType | type, | |||
NPStream * | stream, | |||
NPBool | seekable, | |||
uint16 * | stype | |||
) |
Definition at line 649 of file RioBrowserPlugin.c.
00651 { 00652 PluginInstance* This; 00653 00654 #ifdef RIO_DEBUG1 00655 fprintf( stderr, "[RioBrowserPlugin - NPP_NewStream] Start\n" ); 00656 #endif 00657 00658 if (instance == NULL) 00659 return NPERR_INVALID_INSTANCE_ERROR; 00660 00661 This = ( PluginInstance* ) instance->pdata; 00662 00663 #ifdef RIO_DEBUG1 00664 fprintf( stderr, "[RioBrowserPlugin - NPP_NewStream] Finish\n" ); 00665 #endif 00666 00667 return NPERR_NO_ERROR; 00668 }
Definition at line 769 of file RioBrowserPlugin.c.
Definition at line 575 of file RioBrowserPlugin.c.
00576 { 00577 int port = 0; 00578 NPError result; 00579 PluginInstance *This; 00580 00581 #ifdef RIO_DEBUG1 00582 fprintf( stderr, "[RioBrowserPlugin - NPP_SetWindow] Start\n" ); 00583 #endif 00584 00585 result = NPERR_INVALID_INSTANCE_ERROR; 00586 if( instance != NULL ) 00587 { 00588 This = ( PluginInstance * )instance->pdata; 00589 00590 /* 00591 * PLUGIN DEVELOPERS: 00592 * Before setting window to point to the 00593 * new window, you may wish to compare the new window 00594 * info to the previous window (if any) to note window 00595 * size changes, etc. 00596 */ 00597 This->window = ( Window ) window->window; 00598 This->x = window->x; 00599 This->y = window->y; 00600 This->width = window->width; 00601 This->height = window->height; 00602 This->fWindow = window; 00603 This->display = ( ( NPSetWindowCallbackStruct * ) window->ws_info ) 00604 ->display; 00605 00606 switch( This->mask ) 00607 { 00608 case MASK_MPLAYER: 00609 mID = This->window; 00610 break; 00611 case MASK_RIOCLIENT: 00612 rID = This->window; 00613 break; 00614 case MASK_TGIF: 00615 tID = This->window; 00616 break; 00617 case MASK_INDEX: 00618 iID = This->window; 00619 break; 00620 } 00621 00622 if( isComplete() ) 00623 { 00624 if( ( MaskComplete & MASK_MPLAYER ) != 0 && 00625 ( MaskComplete & MASK_RIOCLIENT ) != 0 ) 00626 { 00627 if( ( MaskComplete & MASK_TGIF ) == 0 ) 00628 if( ( port = startListenerThread( instance ) ) == 0 ) 00629 { 00630 fprintf( stderr, "[cederj]: Could not find a free " ); 00631 fprintf( stderr, "UDP port\n" ); 00632 } 00633 startRioClient( This, port ); 00634 } 00635 MaskComplete = CurMask = 0; 00636 mID = rID = tID = iID = 0; 00637 } 00638 result = NPERR_NO_ERROR; 00639 } 00640 00641 #ifdef RIO_DEBUG1 00642 fprintf( stderr, "[RioBrowserPlugin - NPP_SetWindow] Finish\n" ); 00643 #endif 00644 00645 return result; 00646 }
void NPP_Shutdown | ( | void | ) |
Definition at line 454 of file RioBrowserPlugin.c.
00455 { 00456 int error; 00457 00458 #ifdef RIO_DEBUG1 00459 fprintf( stderr, "[RioBrowserPlugin - NPP_Shutdown] Start\n" ); 00460 #endif 00461 00462 // Remove o semaforo, se estivermos usando a nova implementacao 00463 00464 if( UseChangeSlide ) 00465 { 00466 #ifdef RIO_DEBUG2 00467 fprintf( stderr, "NPP_Shutdown: Removendo o semaforo criado!\n" ); 00468 #endif 00469 if( sem_destroy( &ChangeSlideSemaphore ) < 0 ) 00470 { 00471 error = errno; 00472 fprintf( stderr, "[cederj]: sem_destroy failed with error " ); 00473 fprintf( stderr, "%d (%s)\n", error, strerror( error ) ); 00474 } 00475 } 00476 00477 #ifdef RIO_DEBUG1 00478 fprintf( stderr, "[RioBrowserPlugin - NPP_Shutdown] Finish\n" ); 00479 #endif 00480 }
Definition at line 752 of file RioBrowserPlugin.c.
00753 { 00754 PluginInstance *This; 00755 00756 #ifdef RIO_DEBUG1 00757 fprintf( stderr, "[RioBrowserPlugin - NPP_StreamAsFile] Start\n" ); 00758 #endif 00759 00760 if( instance != NULL ) 00761 This = ( PluginInstance * )instance->pdata; 00762 00763 #ifdef RIO_DEBUG1 00764 fprintf( stderr, "[RioBrowserPlugin - NPP_StreamAsFile] Finish\n" ); 00765 #endif 00766 }
Definition at line 778 of file RioBrowserPlugin.c.
Definition at line 706 of file RioBrowserPlugin.c.
00708 { 00709 PluginInstance *This; 00710 00711 #ifdef RIO_DEBUG1 00712 fprintf( stderr, "[RioBrowserPlugin - NPP_Write] Start\n" ); 00713 #endif 00714 00715 if( instance != NULL ) 00716 This = ( PluginInstance * )instance->pdata; 00717 00718 #ifdef RIO_DEBUG1 00719 fprintf( stderr, "[RioBrowserPlugin - NPP_Write] Finish\n" ); 00720 #endif 00721 00722 return len; /* The number of bytes accepted */ 00723 }
Definition at line 686 of file RioBrowserPlugin.c.
00687 { 00688 PluginInstance *This; 00689 00690 #ifdef RIO_DEBUG1 00691 fprintf( stderr, "[RioBrowserPlugin - NPP_WriteReady] Start\n" ); 00692 #endif 00693 00694 if( instance != NULL ) 00695 This = ( PluginInstance * )instance->pdata; 00696 00697 #ifdef RIO_DEBUG1 00698 fprintf( stderr, "[RioBrowserPlugin - NPP_WriteReady] Finish\n" ); 00699 #endif 00700 00701 /* Number of bytes ready to accept in NPP_Write() */ 00702 return STREAMBUFSIZE; 00703 }
static int startListenerThread | ( | NPP | instance | ) | [static] |
Definition at line 169 of file RioBrowserPlugin.c.
00170 { 00171 int soc, port; 00172 unsigned int size_myaddr; 00173 pthread_t tid; 00174 struct sockaddr_in saddr, myaddr; 00175 ThreadParam *param; 00176 00177 #ifdef RIO_DEBUG1 00178 fprintf( stderr, "[RioBrowserPlugin - startListenerThread] Start\n" ); 00179 #endif 00180 00181 port = 0; 00182 soc = socket( PF_INET, SOCK_DGRAM, 0 ); 00183 saddr.sin_port = 0; 00184 saddr.sin_family = AF_INET; 00185 saddr.sin_addr.s_addr = INADDR_ANY; 00186 if( bind( soc, ( struct sockaddr * ) &saddr, sizeof( saddr ) ) == 0 ) 00187 { 00188 param = NPN_MemAlloc( sizeof( ThreadParam ) ); 00189 param->instance = instance; 00190 param->soc = soc; 00191 if( pthread_create( &tid, NULL, listenerThread, ( void * ) param ) 00192 != 0 ) 00193 { 00194 fprintf( stderr, "[cederj]: Could not create listener thread\n" ); 00195 NPN_MemFree( param ); 00196 } 00197 else 00198 { 00199 size_myaddr = sizeof( myaddr ); 00200 getsockname( soc, ( struct sockaddr * ) &myaddr, &size_myaddr ); 00201 port = myaddr.sin_port; 00202 } 00203 } 00204 else 00205 perror( "bind" ); 00206 00207 #ifdef RIO_DEBUG1 00208 fprintf( stderr, "[RioBrowserPlugin - startListenerThread] Finish\n" ); 00209 #endif 00210 00211 return port; 00212 }
static void startRioClient | ( | PluginInstance * | this, | |
int | port | |||
) | [static] |
Definition at line 214 of file RioBrowserPlugin.c.
00215 { 00216 int argc; 00217 char *argv[ 20 ]; 00218 char serverAndFile[ 255 ]; 00219 char aux_str[ 16 ]; 00220 00221 #ifdef RIO_DEBUG1 00222 fprintf( stderr, "[RioBrowserPlugin - startRioClient] Start\n" ); 00223 #endif 00224 00225 signal( SIGCHLD, SIG_IGN ); 00226 00227 if( ( this->pid = fork() ) != 0 ) 00228 { 00229 if( this->pid < 0 ) 00230 perror( "fork(). Failed to fork process." ); 00231 } 00232 else 00233 { 00234 argc = 0; 00235 argv[ argc++ ] = strdup( "riommclient" ); 00236 argv[ argc++ ] = strdup( "--usecache" ); 00237 argv[ argc++ ] = strdup( "0" ); 00238 00239 /* client window */ 00240 argv[ argc++ ] = strdup( "--mainwindow" ); 00241 sprintf( aux_str, "%d", rID ); 00242 argv[ argc++ ] = strdup( aux_str ); 00243 00244 /* mplayer window */ 00245 argv[ argc++ ] = strdup( "--vid" ); 00246 sprintf( aux_str, "%d", mID ); 00247 argv[ argc++ ] = strdup( aux_str ); 00248 00249 if( tID ) 00250 { 00251 argv[ argc++ ] = strdup( "--tgifWindow" ); 00252 sprintf( aux_str, "%d", tID ); 00253 argv[ argc++ ] = strdup( aux_str ); 00254 } 00255 00256 if( port ) 00257 { 00258 argv[ argc++ ] = strdup( "--pluginport" ); 00259 sprintf( aux_str, "%d", port ); 00260 argv[ argc++ ] = strdup( aux_str ); 00261 } 00262 00263 /* Server and file name*/ 00264 sprintf( serverAndFile, "%s:%s", server, media ); 00265 argv[ argc++ ] = strdup( serverAndFile ); 00266 00267 argv[ argc++ ] = NULL; 00268 00269 if( execvp( argv[ 0 ], argv ) < 0 ) 00270 perror( "execlp(): Failed to execute riommclient" ); 00271 } 00272 00273 #ifdef RIO_DEBUG1 00274 fprintf( stderr, "[RioBrowserPlugin - startRioClient] Finish\n" ); 00275 #endif 00276 }
sem_t ChangeSlideSemaphore |
Definition at line 54 of file RioBrowserPlugin.c.
int CurMask |
Definition at line 50 of file RioBrowserPlugin.c.
int iID |
Definition at line 48 of file RioBrowserPlugin.c.
int MaskComplete = 0 |
Definition at line 49 of file RioBrowserPlugin.c.
char media[254] |
Definition at line 52 of file RioBrowserPlugin.c.
int mID = 0 |
Definition at line 48 of file RioBrowserPlugin.c.
int rID = 0 |
Definition at line 48 of file RioBrowserPlugin.c.
char server[128] |
Definition at line 51 of file RioBrowserPlugin.c.
char SlideUrl[255] |
Definition at line 53 of file RioBrowserPlugin.c.
int32 STREAMBUFSIZE = 0X0FFFFFFF |
Definition at line 682 of file RioBrowserPlugin.c.
int tID = 0 |
Definition at line 48 of file RioBrowserPlugin.c.
int UseChangeSlide |
Definition at line 55 of file RioBrowserPlugin.c.