liberipc/src/eripctoolbar.c File Reference

#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include "eripc.h"
#include "eripcclient.h"
#include "eripctoolbar.h"
#include "eripcparser.h"

Go to the source code of this file.

Classes

struct  iconMap_t

Functions

int tbGetIconNumber (void)
const char * tbGetIconName (int iconID)
int tbAppendPlatformIcon (erClientChannel_t channel, int uaID, int iconID, int signal)
int tbSynchronise (erClientChannel_t channel, int uaID, int signal)
int tbRemovePlatformIcon (erClientChannel_t channel, int uaID, int iconID)
int tbSetStatePlatformIcon (erClientChannel_t channel, int uaID, int iconID, int iconState)
int tbDisableUpdate (erClientChannel_t channel, int uaID)
int tbEnableUpdate (erClientChannel_t channel, int uaID)
int tbSelectIconSet (erClientChannel_t channel, int uaID)
int tbClearIconSet (erClientChannel_t channel, int uaID)
int tbParseCommand (char *szCommand, erIpcCmd_t *pCmd)
int tbReportIconClicked (erClientChannel_t channel, int signal, int iconID, int iconState)
int tbReportSynchronised (erClientChannel_t channel, int signal)

Variables

static const iconMap_t g_icon_map_table []


Function Documentation

int tbAppendPlatformIcon ( erClientChannel_t  channel,
int  uaID,
int  iconID,
int  signal 
)

Append icon with identifier iconID in icon set of application uaID

Parameters:
channel Opaque datastructure that contains info on communication channel
uaID application identifier
iconID icon identifier
signal Signal that will be sent to the application when this icon is clicked
Returns:
A value of 0 signals success

Definition at line 143 of file eripctoolbar.c.

00144 {
00145     erIpcCmd_t cmd;
00146 
00147     strcpy(cmd.name, "tbAppendPlatformIcon");
00148     cmd.cc = (int) ccTbAppendPlatformIcon;
00149     cmd.nArg = 3;
00150     sprintf(cmd.arg[0], "%d", uaID);
00151     sprintf(cmd.arg[1], "%d", iconID);
00152     sprintf(cmd.arg[2], "%d", signal);
00153 
00154     return erIpcSndCommand(channel, &cmd);
00155 }

Here is the call graph for this function:

int tbClearIconSet ( erClientChannel_t  channel,
int  uaID 
)

Remove all Icons from an Icon set

Parameters:
channel Opaque datastructure that contains info on communication channel
uaID application identifier
Returns:
A value of 0 signals success

Definition at line 234 of file eripctoolbar.c.

00235 {
00236     erIpcCmd_t cmd;
00237 
00238     strcpy(cmd.name, "tbClearIconSet");
00239     cmd.cc = (int) ccTbClearIconSet;
00240     cmd.nArg = 1;
00241     sprintf(cmd.arg[0], "%d", uaID);
00242 
00243     return erIpcSndCommand(channel, &cmd);
00244 }

Here is the call graph for this function:

int tbDisableUpdate ( erClientChannel_t  channel,
int  uaID 
)

All effective changes to the Icon state are postponed until a call to tbEnableUpdate

Parameters:
channel Opaque datastructure that contains info on communication channel
uaID application identifier
Returns:
A value of 0 signals success

Definition at line 198 of file eripctoolbar.c.

00199 {
00200     erIpcCmd_t cmd;
00201 
00202     strcpy(cmd.name, "tbDisableUpdate");
00203     cmd.cc = (int) ccTbDisableUpdate;
00204     cmd.nArg = 1;
00205     sprintf(cmd.arg[0], "%d", uaID);
00206 
00207     return erIpcSndCommand(channel, &cmd);
00208 }

Here is the call graph for this function:

int tbEnableUpdate ( erClientChannel_t  channel,
int  uaID 
)

Make all postponed changes to the Icon state effective

Parameters:
channel Opaque datastructure that contains info on communication channel
uaID application identifier
Returns:
A value of 0 signals success

Definition at line 210 of file eripctoolbar.c.

00211 {
00212     erIpcCmd_t cmd;
00213 
00214     strcpy(cmd.name, "tbEnableUpdate");
00215     cmd.cc = (int) ccTbEnableUpdate;
00216     cmd.nArg = 1;
00217     sprintf(cmd.arg[0], "%d", uaID);
00218 
00219     return erIpcSndCommand(channel, &cmd);
00220 }

Here is the call graph for this function:

const char* tbGetIconName ( int  iconID  ) 

Definition at line 122 of file eripctoolbar.c.

00123 {
00124     int         i, nIcons;
00125     const char* iconName = NULL;
00126     
00127     nIcons = tbGetIconNumber();
00128     if ((iconID >= 0) && (iconID <= nIcons))
00129     {
00130         for (i = 0; i < nIcons; i++)
00131         {
00132             if (g_icon_map_table[i].iconID == iconID)
00133             {
00134                 iconName = g_icon_map_table[i].iconName;
00135                 break;
00136             }
00137         }
00138     }
00139 
00140     return iconName;
00141 }

Here is the call graph for this function:

int tbGetIconNumber ( void   ) 

Definition at line 115 of file eripctoolbar.c.

00116 {
00117     int nIcons;
00118     nIcons = sizeof(g_icon_map_table) / sizeof(g_icon_map_table[0]);
00119     return nIcons;
00120 }

int tbParseCommand ( char *  szCommand,
erIpcCmd_t pCmd 
)

Definition at line 252 of file eripctoolbar.c.

00253 {
00254     int     i;
00255     char   *pChar;
00256     int     cmdcode;
00257     char    szToken[TB_MAXCHARONLINE];
00258     int     nReqArgs = 0;
00259 
00260     pCmd->cc = (int) ccUndefined;
00261     for (i = 0; i < TB_N_ARG; i++)
00262     {
00263         strcpy(pCmd->arg[i], "");
00264     }
00265 
00266     // Parse Command
00267     pChar = szCommand;
00268     i = 0;
00269     while (*pChar != '\0')
00270     {
00271         szToken[i] = '\0';
00272         if (*pChar == ',')
00273         {
00274             pChar++;
00275             break;
00276         }
00277         szToken[i] = *pChar++;
00278         i++;
00279         szToken[i] = '\0';
00280     }
00281 
00282     // We have found the command Token. Figure out what the command is.
00283     // TODO: stop doing this hardcoded, rely on a smart datastructure instead.
00284 
00285     if (isdigit(szToken[0]))
00286     {
00287         cmdcode = atoi(szToken);
00288     }
00289     else
00290     {
00291         cmdcode = -1;
00292     }
00293     if (strcmp(szToken, "tbAppendPlatformIcon") == 0 || cmdcode == ccTbAppendPlatformIcon)
00294     {
00295         strcpy(pCmd->name, szToken);
00296         pCmd->cc = (int) ccTbAppendPlatformIcon;
00297         nReqArgs = 3;
00298         pCmd->nArg = 3;
00299     }
00300     else if (strcmp(szToken, "tbRemovePlatformIcon") == 0 || cmdcode == ccTbRemovePlatformIcon)
00301     {
00302         strcpy(pCmd->name, szToken);
00303         pCmd->cc = (int) ccTbRemovePlatformIcon;
00304         nReqArgs = 2;
00305         pCmd->nArg = 2;
00306     }
00307     else if (strcmp(szToken, "tbSetStatePlatformIcon") == 0 || cmdcode == ccTbSetStatePlatformIcon)
00308     {
00309         strcpy(pCmd->name, szToken);
00310         pCmd->cc = (int) ccTbSetStatePlatformIcon;
00311         nReqArgs = 3;
00312         pCmd->nArg = 3;
00313     }
00314     else if (strcmp(szToken, "tbDisableUpdate") == 0 || cmdcode == ccTbDisableUpdate)
00315     {
00316         strcpy(pCmd->name, szToken);
00317         pCmd->cc = (int) ccTbDisableUpdate;
00318         nReqArgs = 1;
00319         pCmd->nArg = 1;
00320     }
00321     else if (strcmp(szToken, "tbEnableUpdate") == 0 || cmdcode == ccTbEnableUpdate)
00322     {
00323         strcpy(pCmd->name, szToken);
00324         pCmd->cc = (int) ccTbEnableUpdate;
00325         nReqArgs = 1;
00326         pCmd->nArg = 1;
00327     }
00328     else if (strcmp(szToken, "tbSelectIconSet") == 0 || cmdcode == ccTbSelectIconSet)
00329     {
00330         strcpy(pCmd->name, szToken);
00331         pCmd->cc = (int) ccTbSelectIconSet;
00332         nReqArgs = 1;
00333         pCmd->nArg = 1;
00334     }
00335     else if (strcmp(szToken, "tbClearIconSet") == 0 || cmdcode == ccTbClearIconSet)
00336     {
00337         strcpy(pCmd->name, szToken);
00338         pCmd->cc = (int) ccTbClearIconSet;
00339         nReqArgs = 1;
00340         pCmd->nArg = 1;
00341     }
00342     else if (strcmp(szToken, "tbSynchronise") == 0 || cmdcode == ccTbSynchronise)
00343     {
00344         strcpy(pCmd->name, szToken);
00345         pCmd->cc = (int) ccTbSynchronise;
00346         nReqArgs = 2;
00347         pCmd->nArg = 2;
00348     }
00349     else
00350     {
00351         strcpy(pCmd->name, "Undefined");
00352         pCmd->cc = (int) ccUndefined;
00353         fprintf(stderr, "%s: Command %s \n", __FUNCTION__, szToken);
00354         fprintf(stderr, "Error parsing (%s). Command undefined\n", szCommand);
00355         pCmd->nArg = -1;
00356         return -1;
00357     }
00358 
00359     if (nReqArgs > 0)
00360     {
00361         erIpcGetArgs(pChar, pCmd, nReqArgs);
00362     }
00363     return 0;
00364 }

Here is the call graph for this function:

int tbRemovePlatformIcon ( erClientChannel_t  channel,
int  uaID,
int  iconID 
)

Remove icon with identifier iconID in icon set of application uaID

Parameters:
channel Opaque datastructure that contains info on communication channel
uaID application identifier
iconID icon identifier
Returns:
A value of 0 signals success

Definition at line 170 of file eripctoolbar.c.

00171 {
00172     erIpcCmd_t cmd;
00173 
00174     strcpy(cmd.name, "tbRemovePlatformIcon");
00175     cmd.cc = (int) ccTbRemovePlatformIcon;
00176     cmd.nArg = 2;
00177     sprintf(cmd.arg[0], "%d", uaID);
00178     sprintf(cmd.arg[1], "%d", iconID);
00179 
00180     return erIpcSndCommand(channel, &cmd);
00181 }

Here is the call graph for this function:

int tbReportIconClicked ( erClientChannel_t  channel,
int  signal,
int  iconID,
int  iconState 
)

Definition at line 368 of file eripctoolbar.c.

00369 {
00370     erIpcCmd_t cmd;
00371 
00372     strcpy(cmd.name, "tbIconClicked");
00373     cmd.cc = signal;
00374     cmd.nArg = 2;
00375     sprintf(cmd.arg[0], "%d", iconID);
00376     sprintf(cmd.arg[1], "%d", iconState);
00377 
00378     return erIpcSndCommand(channel, &cmd);
00379 }

Here is the call graph for this function:

int tbReportSynchronised ( erClientChannel_t  channel,
int  signal 
)

Definition at line 382 of file eripctoolbar.c.

00383 {
00384     erIpcCmd_t cmd;
00385 
00386     strcpy(cmd.name, "tbSynchronise");
00387     cmd.cc = signal;
00388     cmd.nArg = 0;
00389 
00390     return erIpcSndCommand(channel, &cmd);
00391 }

Here is the call graph for this function:

int tbSelectIconSet ( erClientChannel_t  channel,
int  uaID 
)

Select and display an Icon set

Parameters:
channel Opaque datastructure that contains info on communication channel
uaID application identifier
Returns:
A value of 0 signals success

Definition at line 222 of file eripctoolbar.c.

00223 {
00224     erIpcCmd_t cmd;
00225 
00226     strcpy(cmd.name, "tbSelectIconSet");
00227     cmd.cc = (int) ccTbSelectIconSet;
00228     cmd.nArg = 1;
00229     sprintf(cmd.arg[0], "%d", uaID);
00230 
00231     return erIpcSndCommand(channel, &cmd);
00232 }

Here is the call graph for this function:

int tbSetStatePlatformIcon ( erClientChannel_t  channel,
int  uaID,
int  iconID,
int  iconState 
)

Set state (i.e. bitmap image) for icon with identifier iconID in icon set of application uaID

Parameters:
channel Opaque datastructure that contains info on communication channel
uaID application identifier
iconID icon identifier
iconState icon state, i.e. index in bitmap images
Returns:
A value of 0 signals success

Definition at line 184 of file eripctoolbar.c.

00185 {
00186     erIpcCmd_t cmd;
00187 
00188     strcpy(cmd.name, "tbSetStatePlatformIcon");
00189     cmd.cc = (int) ccTbSetStatePlatformIcon;
00190     cmd.nArg = 3;
00191     sprintf(cmd.arg[0], "%d", uaID);
00192     sprintf(cmd.arg[1], "%d", iconID);
00193     sprintf(cmd.arg[2], "%d", iconState);
00194 
00195     return erIpcSndCommand(channel, &cmd);
00196 }

Here is the call graph for this function:

int tbSynchronise ( erClientChannel_t  channel,
int  uaID,
int  signal 
)

Acknowledge "synchronise" message

Parameters:
channel Opaque datastructure that contains info on communication channel
uaID application identifier
signal Signal that will be sent to the application
Returns:
A value of 0 signals success

Definition at line 157 of file eripctoolbar.c.

00158 {
00159     erIpcCmd_t cmd;
00160 
00161     strcpy(cmd.name, "tbSynchronise");
00162     cmd.cc = (int) ccTbSynchronise;
00163     cmd.nArg = 2;
00164     sprintf(cmd.arg[0], "%d", uaID);
00165     sprintf(cmd.arg[1], "%d", signal);
00166 
00167     return erIpcSndCommand(channel, &cmd);
00168 }

Here is the call graph for this function:


Variable Documentation

const iconMap_t g_icon_map_table[] [static]

Definition at line 45 of file eripctoolbar.c.


Generated on Sun Dec 14 17:11:48 2008 by  doxygen 1.5.6