Beispiel #1
0
/*
 * @file stream.c
 * @brief ICE stream functionality
 */
Stream *
stream_new (guint n_components)
{
  Stream *stream;
  guint n;
  gboolean errors = FALSE;
  GSList *modified_list;
  Component *component;

  stream = g_slice_new0 (Stream);
  for (n = 0; n < n_components; n++) {
    component = component_new (n + 1);
    if (component) {
      modified_list = g_slist_append (stream->components, component);
      if (modified_list)
	stream->components = modified_list;
      else 
	errors = TRUE;
    }
    else
      errors = TRUE;
  }

  if (errors) {
    stream_free (stream);
    return NULL;
  }

  stream->n_components = n_components;
  stream->initial_binding_request_received = FALSE;

  return stream;
}
Beispiel #2
0
component_t *
cache_open (
   bundle_t *bundlePtr,
   const char *name
) {
   XML_Parser parser;
   component_t *componentPtr = NULL;
   char *path = NULL;
   char buffer [256];
   xc_result_t result = XC_ERR_INVAL;
   int fd;

   TRACE3 (("called with bundlePtr=%p", bundlePtr));
   assert (bundlePtr != NULL);

   path = malloc (PATH_MAX);
   if (path != NULL) {
      sprintf (path, "%s/" CACHE_FOLDER "/" XC_HOST "/%s.xml", bundlePtr->path, name);
      fd = open (path, O_RDONLY);
      if (fd >= 0) {
         parser = XML_ParserCreate (NULL);
         if (parser != NULL) {
            componentPtr = component_new (bundlePtr);
            if (componentPtr != NULL) {
               sprintf (path, "%s/" CODE_FOLDER "/" XC_HOST "/%s", bundlePtr->path, name);
               componentPtr->path = path;
               path = NULL;
               XML_SetUserData (parser, componentPtr);
               XML_SetElementHandler (parser, handle_cache_start_tag, NULL);
               for (;;) {
                  int n = read (fd, buffer, sizeof (buffer));
                  if (n < 0) break;
                  if (!XML_Parse (parser, buffer, n, n==0)) break;
                  if (n==0) {
                     TRACE4 (("%s: loaded meta-data from cache!", componentPtr->name));
                     result = XC_OK;
                     break;
                  }
               }
            }
            XML_ParserFree (parser);
         }
         close (fd);
      }
      else {
         TRACE2 (("%s: failed to open", path));
      }
   }
   
   if (result != XC_OK) {
      if (componentPtr != NULL) {
         component_free (componentPtr);
         componentPtr = NULL;
      }
      free (path);
   }

   TRACE3 (("exiting with result=%p", componentPtr));
   return componentPtr;
}
Component *button_new(
    Uint32        id,
    Word        name,
    RectFloat   rect,
    RectFloat        bounds,
    char         * buttonText,
    Uint32        fontSize,
    Uint32        buttonType,
    int         buttonHotkey,
    Uint32        buttonHotkeymod,
    int        center,
    int         justify,
    char         * buttonFileUp,
    char         * buttonFileHigh,
    char         * buttonFileDown,
    Vec3D       backgroundColor,
    float       backgroundAlpha,
    Vec3D       highlightColor,
    Vec3D       pressColor
)
{
    int i;
    ComponentButton *button = NULL;
    Component *component = NULL;
    component = component_new();
    if (!component)return NULL;
    component_make_button(
        component,
        buttonText,
        justify,
        buttonType,
        buttonHotkey,
        buttonHotkeymod,
        buttonFileUp,
        buttonFileHigh,
        buttonFileDown,
        backgroundColor,
        backgroundAlpha,
        highlightColor,
        pressColor,
        fontSize
    );
    rect_copy(&component->rect,rect);
    button = component_get_button_data(component);
    if (button == NULL)
    {
        component_free(&component);
        return NULL;
    }
    button->centered = center;
    component->id = id;
    strncpy(component->name,name,WORDLEN);
    component->type = ButtonComponent;
    component->data_move = button_move;
    for (i = 0; i < ButtonStateMax; i++)
    {
        vec3d_cpy(button->textColor[i],__component_button_color[i]);
    }
    button_move(component,bounds);
    component_button_set_activation(component,
                                    __component_button_release_active,
                                    __component_button_press_active,
                                    __component_button_hold_active);
    return component;
}