Пример #1
0
static void
tail_align (gpointer ptr,
            gsize size,
            const AlignmentCriteria * criteria,
            TailAlignResult * result)
{
  gsize unaligned_start_address, unaligned_end_address;
  gsize next_tail_boundary;
  gsize aligned_start_address, aligned_end_address;

  unaligned_start_address = GPOINTER_TO_SIZE (ptr);
  unaligned_end_address = unaligned_start_address + size - 1;
  next_tail_boundary = ((unaligned_end_address / criteria->tail) + 1) * criteria->tail;

  aligned_start_address = ((next_tail_boundary - size) / criteria->front) * criteria->front;
  if (aligned_start_address < unaligned_start_address)
  {
    aligned_start_address += criteria->tail;
    next_tail_boundary += criteria->tail;
  }
  aligned_end_address = aligned_start_address + size - 1;

  result->aligned_ptr = GSIZE_TO_POINTER (aligned_start_address);
  result->next_tail_ptr = GSIZE_TO_POINTER (next_tail_boundary);
  result->gap_size = next_tail_boundary - (aligned_end_address + 1);
}
Пример #2
0
void torflowrelay_addMeasurement(TorFlowRelay* relay,
        gsize contentLength, gsize roundTripTime, gsize payloadTime, gsize totalTime) {
    g_assert(relay);

    relay->transferTimes = g_slist_prepend(relay->transferTimes, GSIZE_TO_POINTER(totalTime));
    relay->transferSizes = g_slist_prepend(relay->transferSizes, GSIZE_TO_POINTER(contentLength));
}
Пример #3
0
int build_address_lookup(char* first_snapshot, char* second_snapshot) {
    ssize_t rc;
    char* line;
    size_t len = 0;
    uint32_t addr;
    u_long taint_val;

    address_lookup = g_hash_table_new(g_direct_hash, g_direct_equal); 
    second_address_lookup = g_hash_table_new(g_direct_hash, g_direct_equal); 
   
/*  First Snapshot ############################################# */
    FILE* fp = fopen(first_snapshot, "r");
    assert(fp);
    while ((rc = getline(&line, &len, fp)) != -1) {
        sscanf(line, "%x: %lu\n", &addr, &taint_val);
        g_hash_table_insert(address_lookup, GUINT_TO_POINTER(addr), GSIZE_TO_POINTER(taint_val));
    }
    
/*  Second Snapshot ############################################# */
    fp = fopen(second_snapshot, "r");
    assert(fp);
    while ((rc = getline(&line, &len, fp)) != -1) {
        sscanf(line, "%x: %lu\n", &addr, &taint_val);
        g_hash_table_insert(second_address_lookup, GUINT_TO_POINTER(addr), GSIZE_TO_POINTER(taint_val));
    }
    return 1;
}
Пример #4
0
static GHashTable *
meta_wayland_compositor_update_outputs (MetaWaylandCompositor *compositor,
                                        MetaMonitorManager    *monitors)
{
  unsigned int i;
  GHashTable *new_table;
  MetaMonitorInfo *monitor_infos;
  unsigned int n_monitor_infos;

  monitor_infos = meta_monitor_manager_get_monitor_infos (monitors, &n_monitor_infos);
  new_table = g_hash_table_new_full (NULL, NULL, NULL, wayland_output_destroy_notify);

  for (i = 0; i < n_monitor_infos; i++)
    {
      MetaMonitorInfo *info = &monitor_infos[i];
      MetaWaylandOutput *wayland_output;

      if (info->winsys_id == 0)
        continue;
      wayland_output = g_hash_table_lookup (compositor->outputs, GSIZE_TO_POINTER (info->winsys_id));

      if (wayland_output)
        {
          g_hash_table_steal (compositor->outputs, GSIZE_TO_POINTER (info->winsys_id));
        }
      else
        wayland_output = meta_wayland_output_new (compositor, info);

      wayland_output_update_for_output (wayland_output, info);
      g_hash_table_insert (new_table, GSIZE_TO_POINTER (info->winsys_id), wayland_output);
    }

  g_hash_table_destroy (compositor->outputs);
  return new_table;
}
Пример #5
0
void
glx_ctx_push_thread_local(VdpDeviceData *deviceData)
{
    glx_ctx_lock();
    Display *dpy = deviceData->display;
    const Window wnd = deviceData->root;
    thread_id_t thread_id = get_current_thread_id();

    ctx_stack.dpy = glXGetCurrentDisplay();
    if (!ctx_stack.dpy)
        ctx_stack.dpy = dpy;
    ctx_stack.wnd =     glXGetCurrentDrawable();
    ctx_stack.glc =     glXGetCurrentContext();
    ctx_stack.element_count ++;

    struct val_s *val = g_hash_table_lookup(glc_hash_table, GSIZE_TO_POINTER(thread_id));
    if (!val) {
        GLXContext glc = glXCreateContext(dpy, root_vi, root_glc, GL_TRUE);
        assert(glc);
        val = make_val(dpy, glc);
        g_hash_table_insert(glc_hash_table, GSIZE_TO_POINTER(thread_id), val);

        // try cleanup expired entries
        g_hash_table_foreach_remove(glc_hash_table, is_thread_expired, NULL);
    }
    assert(val->dpy == dpy);

    glXMakeCurrent(dpy, wnd, val->glc);
}
Пример #6
0
/**
 * _gtk_css_style_parse_value:
 * @value: the value to parse into. Must be a valid initialized #GValue
 * @parser: the parser to parse from
 *
 * This is the generic parsing function used for CSS values. If the
 * function fails to parse a value, it will emit an error on @parser,
 * return %FALSE and not touch @value.
 *
 * Returns: %TRUE if parsing succeeded.
 **/
gboolean
_gtk_css_style_funcs_parse_value (GValue       *value,
                                  GtkCssParser *parser)
{
  GtkStyleParseFunc func;

  g_return_val_if_fail (value != NULL, FALSE);
  g_return_val_if_fail (parser != NULL, FALSE);

  gtk_css_style_funcs_init ();

  func = g_hash_table_lookup (parse_funcs,
                              GSIZE_TO_POINTER (G_VALUE_TYPE (value)));
  if (func == NULL)
    func = g_hash_table_lookup (parse_funcs,
                                GSIZE_TO_POINTER (g_type_fundamental (G_VALUE_TYPE (value))));

  if (func == NULL)
    {
      _gtk_css_parser_error (parser,
                             "Cannot convert to type '%s'",
                             g_type_name (G_VALUE_TYPE (value)));
      return FALSE;
    }

  return (*func) (parser, value);
}
Пример #7
0
static void
_insert_grl_mex_link (GrlKeyID grl_key, MexContentMetadata mex_key)
{
  /* g_hash_table_insert (grl_to_mex, */
  /*                      GSIZE_TO_POINTER (grl_key), */
  /*                      GSIZE_TO_POINTER (mex_key)); */
  g_hash_table_insert (mex_to_grl,
                       GSIZE_TO_POINTER (mex_key),
                       GSIZE_TO_POINTER (grl_key));
}
Пример #8
0
static void
register_conversion_function (GType               type,
                              GtkStyleParseFunc   parse,
                              GtkStylePrintFunc   print)
{
  if (parse)
    g_hash_table_insert (parse_funcs, GSIZE_TO_POINTER (type), parse);
  if (print)
    g_hash_table_insert (print_funcs, GSIZE_TO_POINTER (type), print);
}
Пример #9
0
static void
register_conversion_function (GType          type,
                              ParseFunc      parse,
                              ToStringFunc   to_string)
{
  if (parse)
    g_hash_table_insert (parse_funcs, GSIZE_TO_POINTER (type), parse);
  if (to_string)
    g_hash_table_insert (to_string_funcs, GSIZE_TO_POINTER (type), to_string);
}
Пример #10
0
static gboolean
ipcam_event_input_msg_handler_read_param(IpcamEventInputMsgHandler *handler, JsonBuilder *builder, const gchar *name)
{
    IpcamIConfig *iconfig;
    g_object_get(G_OBJECT(handler), "app", &iconfig, NULL);
    gboolean ret = FALSE;
    GVariant *value = NULL;

    value = ipcam_iconfig_read(iconfig, IPCAM_EVENT_INPUT_TYPE, name, "enable");
    if (value)
    {
        json_builder_set_member_name(builder, "enable");
        json_builder_add_boolean_value(builder, g_variant_get_boolean(value));
        g_variant_unref(value);
    }
    
    value = ipcam_iconfig_read(iconfig, IPCAM_EVENT_INPUT_TYPE, name, "schedules");
    if (value)
    {
        Schedules *sche;
        if (IS_64BIT_MACHINE)
        {
            sche = GSIZE_TO_POINTER(g_variant_get_uint64(value));
        }
        else
        {
            sche = GSIZE_TO_POINTER(g_variant_get_uint32(value));
        }
        gint i = 0;
        json_builder_set_member_name(builder, "schedules");
        json_builder_begin_object(builder);
        if (sche)
        {            
            for (i = ENUM_MON; i < ENUM_WEEKDAY_LAST; i++)
            {
                if (sche->schedule[i])
                {
                    json_builder_set_member_name(builder, weekday_name[i]);
                    json_builder_add_string_value(builder, sche->schedule[i]);
                    g_free(sche->schedule[i]);
                }
            }
            g_free(sche);
        }
        json_builder_end_object(builder);

        g_variant_unref(value);
    }
    
    return ret;
}
Пример #11
0
static void
main_loop ()
{
  log_write ("openvassd %s started\n", OPENVASSD_VERSION);
  proctitle_set ("openvassd: Waiting for incoming connections");
  for (;;)
    {
      int soc;
      int family;
      unsigned int lg_address;
      struct sockaddr_in6 address6;
      struct sockaddr_in6 *p_addr;
      struct arglist *globals;
      struct addrinfo *ai;

      check_and_reload ();
      wait_for_children1 ();
      ai = arg_get_value (g_options, "addr");
      lg_address = sizeof (struct sockaddr_in6);
      soc = accept (global_iana_socket, (struct sockaddr *) (&address6),
                    &lg_address);
      if (soc == -1)
        continue;

      /*
       * MA: you cannot share an open SSL connection through fork/multithread
       * The SSL connection shall be open _after_ the fork */
      globals = emalloc (sizeof (struct arglist));
      arg_add_value (globals, "global_socket", ARG_INT, -1,
                     GSIZE_TO_POINTER (soc));

      arg_add_value (globals, "plugins", ARG_ARGLIST, -1, global_plugins);
      arg_add_value (globals, "preferences", ARG_ARGLIST, -1, global_preferences);

      p_addr = emalloc (sizeof (struct sockaddr_in6));
      family = ai->ai_family;
      memcpy (p_addr, &address6, sizeof (address6));
      arg_add_value (globals, "client_address", ARG_PTR, -1, p_addr);
      arg_add_value (globals, "family", ARG_INT, -1, GSIZE_TO_POINTER (family));

      /* we do not want to create an io thread, yet so the last argument is -1 */
      if (create_process ((process_func_t) scanner_thread, globals) < 0)
        {
          log_write ("Could not fork - client won't be served");
          sleep (2);
        }
      close (soc);
      arg_free (globals);
    }
}
Пример #12
0
static gboolean
gum_store_runtime_bounds (const GumModuleDetails * details,
                          GumRuntimeBounds * bounds)
{
  const GumMemoryRange * range = details->range;

  if (strcmp (details->name, "libandroid_runtime.so") != 0)
    return TRUE;

  bounds->start = GSIZE_TO_POINTER (range->base_address);
  bounds->end = GSIZE_TO_POINTER (range->base_address + range->size);

  return FALSE;
}
Пример #13
0
void
af_animator_register_type_transformation (GType                    type,
                                          AfTypeTransformationFunc trans_func)
{
  if (!transformable_types)
    transformable_types = g_hash_table_new (g_direct_hash, g_direct_equal);

  if (!trans_func)
    g_hash_table_remove (transformable_types, GSIZE_TO_POINTER (type));
  else
    g_hash_table_insert (transformable_types,
                         GSIZE_TO_POINTER (type),
                         trans_func);
}
Пример #14
0
GumScriptBackend *
gum_script_backend_obtain_v8 (void)
{
  static volatile gsize gonce_value;

  if (g_once_init_enter (&gonce_value))
  {
    GumScriptBackend * backend = NULL;

    if (gum_query_is_rwx_supported ())
    {
#ifdef HAVE_V8
      backend = GUM_SCRIPT_BACKEND (
          g_object_new (GUM_V8_TYPE_SCRIPT_BACKEND, NULL));
#endif

      if (backend != NULL)
        _gum_register_early_destructor (gum_script_backend_deinit_v8);
    }

    g_once_init_leave (&gonce_value, GPOINTER_TO_SIZE (backend) + 1);
  }

  return GUM_SCRIPT_BACKEND (GSIZE_TO_POINTER (gonce_value - 1));
}
Пример #15
0
static gboolean
gum_emit_malloc_range (const GumMallocRangeDetails * details,
                       gpointer user_data)
{
  GumJscMatchContext * mc = user_data;
  GumJscCore * core = mc->self->core;
  GumJscScope scope = GUM_JSC_SCOPE_INIT (core);
  JSContextRef ctx = mc->ctx;
  JSObjectRef range;
  JSValueRef result;
  gboolean proceed;
  gchar * str;

  range = JSObjectMake (ctx, NULL, NULL);
  _gumjs_object_set_pointer (ctx, range, "base",
      GSIZE_TO_POINTER (details->range->base_address), core);
  _gumjs_object_set_uint (ctx, range, "size", details->range->size);

  result = JSObjectCallAsFunction (ctx, mc->on_match, NULL, 1,
      (JSValueRef *) &range, &scope.exception);
  _gum_jsc_scope_flush (&scope);

  proceed = TRUE;
  if (result != NULL && _gumjs_string_try_get (ctx, result, &str, NULL))
  {
    proceed = strcmp (str, "stop") != 0;
    g_free (str);
  }

  return proceed;
}
Пример #16
0
static GSList *
find_image_text_section_ids (gconstpointer address)
{
  GSList * ids = NULL;
  gsize section_count = 0;
  const gum_mach_header_t * header = address;
  guint8 * p;
  guint cmd_index, section_index;

  p = (guint8 *) (header + 1);
  for (cmd_index = 0; cmd_index != header->ncmds; cmd_index++)
  {
    struct load_command * lc = (struct load_command *) p;

    if (lc->cmd == GUM_LC_SEGMENT)
    {
      gum_segment_command_t * segcmd = (gum_segment_command_t *) lc;

      if ((segcmd->initprot & VM_PROT_EXECUTE) != 0)
      {
        for (section_index = 0; section_index != segcmd->nsects; section_index++)
        {
          ids = g_slist_prepend (ids,
              GSIZE_TO_POINTER (section_count + section_index + 1));
        }
      }

      section_count += segcmd->nsects;
    }

    p += lc->cmdsize;
  }

  return g_slist_reverse (ids);
}
Пример #17
0
void
gum_metal_array_get_extents (GumMetalArray * self,
                             gpointer * start,
                             gpointer * end)
{
  GumMemoryRange range;
  guint size;

  size = (guint) ((guint8 *) gum_metal_array_element_at (self, self->capacity) -
      (guint8 *) self->data);
  gum_query_page_allocation_range (self->data, gum_round_up_to_page_size (size),
      &range);

  *start = GSIZE_TO_POINTER (range.base_address);
  *end = GSIZE_TO_POINTER (range.base_address + range.size);
}
static gpointer
tny_gnome_keyring_password_getter_register_type (gpointer notused)
{
	GType type = 0;
	static const GTypeInfo info = 
		{
			sizeof (TnyGnomeKeyringPasswordGetterClass),
			NULL,   /* base_init */
			NULL,   /* base_finalize */
			(GClassInitFunc) tny_gnome_keyring_password_getter_class_init,   /* class_init */
			NULL,   /* class_finalize */
			NULL,   /* class_data */
			sizeof (TnyGnomeKeyringPasswordGetter),
			0,      /* n_preallocs */
			tny_gnome_keyring_password_getter_instance_init,    /* instance_init */
			NULL
		};


	static const GInterfaceInfo tny_password_getter_info = 
		{
			(GInterfaceInitFunc) tny_password_getter_init, /* interface_init */
			NULL,         /* interface_finalize */
			NULL          /* interface_data */
		};

	type = g_type_register_static (G_TYPE_OBJECT,
				       "TnyGnomeKeyringPasswordGetter",
				       &info, 0);

	g_type_add_interface_static (type, TNY_TYPE_PASSWORD_GETTER,
				     &tny_password_getter_info);

	return GSIZE_TO_POINTER (type);
}
Пример #19
0
static void
ensure_module_ifaces (StoragedLinuxDriveObject *object,
                      StoragedModuleManager    *module_manager)
{
    GList *l;
    ModuleInterfaceEntry *entry;
    StoragedModuleInterfaceInfo *ii;

    /* Assume all modules are either unloaded or loaded at the same time, so don't regenerate entries */
    if (object->module_ifaces == NULL)
    {
        object->module_ifaces = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) free_module_interface_entry);

        l = storaged_module_manager_get_drive_object_iface_infos (module_manager);
        for (; l; l = l->next)
        {
            ii = l->data;
            entry = g_new0 (ModuleInterfaceEntry, 1);
            entry->has_func = ii->has_func;
            entry->connect_func = ii->connect_func;
            entry->update_func = ii->update_func;
            g_hash_table_replace (object->module_ifaces, GSIZE_TO_POINTER (ii->skeleton_type), entry);
        }
    }
}
Пример #20
0
void
gom_repository_find_async (GomRepository       *repository,
                           GType                resource_type,
                           GomFilter           *filter,
                           GAsyncReadyCallback  callback,
                           gpointer             user_data)
{
   GomRepositoryPrivate *priv;
   GSimpleAsyncResult *simple;

   g_return_if_fail(GOM_IS_REPOSITORY(repository));
   g_return_if_fail(g_type_is_a(resource_type, GOM_TYPE_RESOURCE));
   g_return_if_fail(resource_type != GOM_TYPE_RESOURCE);
   g_return_if_fail(!filter || GOM_IS_FILTER(filter));
   g_return_if_fail(callback != NULL);

   priv = repository->priv;

   simple = g_simple_async_result_new(G_OBJECT(repository), callback, user_data,
                                      gom_repository_find_async);
   g_object_set_data(G_OBJECT(simple), "resource-type",
                     GSIZE_TO_POINTER(resource_type));

   g_object_set_data_full(G_OBJECT(simple), "filter",
                          filter ? g_object_ref(filter) : NULL,
                          filter ? g_object_unref : NULL);
   gom_adapter_queue_read(priv->adapter, gom_repository_find_cb, simple);
}
Пример #21
0
JSObject *
gjs_gtype_create_gtype_wrapper (JSContext *context,
                                GType      gtype)
{
    JSObject *object;
    JSObject *global;

    JS_BeginRequest(context);

    /* put constructor for GIRepositoryGType() in the global namespace */
    global = gjs_get_import_global(context);
    gjs_gtype_create_proto(context, global, "GIRepositoryGType", NULL);

    object = g_type_get_qdata(gtype, gjs_get_gtype_wrapper_quark());
    if (object != NULL)
        goto out;

    object = JS_NewObject(context, &gjs_gtype_class, NULL, NULL);
    if (object == NULL)
        goto out;

    JS_SetPrivate(context, object, GSIZE_TO_POINTER(gtype));
    g_type_set_qdata(gtype, gjs_get_gtype_wrapper_quark(), object);

 out:
    JS_EndRequest(context);
    return object;
}
Пример #22
0
static void
on_end_element (G_GNUC_UNUSED GMarkupParseContext *context,
                const gchar                       *el_name,
                gpointer                           user_data,
                G_GNUC_UNUSED GError             **error)
{
  CdkStyleScheme *self = CDK_STYLE_SCHEME (user_data);

  if (g_strcmp0 (el_name, "scheme") == 0)
    {
      self->priv->in_scheme_tag = FALSE;
      return;
    }
  else if (self->priv->in_scheme_tag &&
           self->priv->style_id >= 0 &&
           g_strcmp0 (el_name, "style") == 0)
    {
      CdkStyle *style = cdk_style_new ();
      style->fore = self->priv->fore_color;
      style->back = self->priv->back_color;
      style->bold = self->priv->bold;
      style->italic = self->priv->italic;
      style->font = self->priv->font;
      style->size = self->priv->size;

      g_hash_table_insert (self->priv->style_map,
                           GSIZE_TO_POINTER (self->priv->style_id),
                           style);
      //g_debug ("added style '%u'", (guint) self->priv->style_id);
      self->priv->style_id = -1;
    }
}
Пример #23
0
CdkStyleID
cdk_style_id_for_cursor_kind (guint cursor_kind)
{
  if (G_UNLIKELY (cursor_map == NULL))
    return CDK_STYLE_DEFAULT;
  return GPOINTER_TO_SIZE (g_hash_table_lookup (cursor_map, GSIZE_TO_POINTER (cursor_kind)));
}
static gpointer
tny_camel_default_connection_policy_register_type (gpointer notused)
{
	GType type = 0;
	static const GTypeInfo info = 
		{
			sizeof (TnyCamelDefaultConnectionPolicyClass),
			NULL,   /* base_init */
			NULL,   /* base_finalize */
			(GClassInitFunc) tny_camel_default_connection_policy_class_init,   /* class_init */
			NULL,   /* class_finalize */
			NULL,   /* class_data */
			sizeof (TnyCamelDefaultConnectionPolicy),
			0,      /* n_preallocs */
			tny_camel_default_connection_policy_instance_init,    /* instance_init */
			NULL
		};
	
	
	static const GInterfaceInfo tny_connection_policy_info = 
		{
			(GInterfaceInitFunc) tny_connection_policy_init, /* interface_init */
			NULL,         /* interface_finalize */
			NULL          /* interface_data */
		};
	
	type = g_type_register_static (G_TYPE_OBJECT,
				       "TnyCamelDefaultConnectionPolicy",
				       &info, 0);
	
	g_type_add_interface_static (type, TNY_TYPE_CONNECTION_POLICY,
				     &tny_connection_policy_info);
	
	return GSIZE_TO_POINTER (type);
}
Пример #25
0
static void
nmt_add_connection_constructed (GObject *object)
{
	NmtAddConnectionPrivate *priv = NMT_ADD_CONNECTION_GET_PRIVATE (object);
	NMEditorConnectionTypeData **types;
	char *text;
	int i, num_types;

	if (priv->secondary_text) {
		text = g_strdup_printf ("%s\n\n%s",
		                        priv->primary_text,
		                        priv->secondary_text);
	} else
		text = g_strdup (priv->primary_text);
	nmt_newt_textbox_set_text (priv->textbox, text);
	g_free (text);

	types = nm_editor_utils_get_connection_type_list ();
	for (i = num_types = 0; types[i]; i++) {
		if (priv->type_filter && !priv->type_filter (types[i]->setting_type, priv->type_filter_data))
			continue;
		nmt_newt_listbox_append (priv->listbox, types[i]->name,
		                         GSIZE_TO_POINTER (types[i]->setting_type));
		num_types++;
	}

	if (num_types == 1)
		priv->single_type = TRUE;

	G_OBJECT_CLASS (nmt_add_connection_parent_class)->constructed (object);
}
static gpointer 
_tny_gtk_attach_list_model_iterator_register_type (gpointer notused)
{
	GType type = 0;

	static const GTypeInfo info = 
		{
		  sizeof (TnyGtkAttachListModelIteratorClass),
		  NULL,   /* base_init */
		  NULL,   /* base_finalize */
		  (GClassInitFunc) tny_gtk_attach_list_model_iterator_class_init,   /* class_init */
		  NULL,   /* class_finalize */
		  NULL,   /* class_data */
		  sizeof (TnyGtkAttachListModelIterator),
		  0,      /* n_preallocs */
		  tny_gtk_attach_list_model_iterator_instance_init    /* instance_init */
		};

	static const GInterfaceInfo tny_iterator_info = 
		{
		  (GInterfaceInitFunc) tny_iterator_init, /* interface_init */
		  NULL,         /* interface_finalize */
		  NULL          /* interface_data */
		};

	type = g_type_register_static (G_TYPE_OBJECT,
				       "TnyGtkAttachListModelIterator",
				       &info, 0);

	g_type_add_interface_static (type, TNY_TYPE_ITERATOR, 
				     &tny_iterator_info);

	return GSIZE_TO_POINTER (type);
}
static gpointer
tny_camel_partial_msg_receive_strategy_register_type (gpointer notused)
{
	GType type = 0;
	static const GTypeInfo info = 
		{
			sizeof (TnyCamelPartialMsgReceiveStrategyClass),
			NULL,   /* base_init */
			NULL,   /* base_finalize */
			(GClassInitFunc) tny_camel_partial_msg_receive_strategy_class_init,   /* class_init */
			NULL,   /* class_finalize */
			NULL,   /* class_data */
			sizeof (TnyCamelPartialMsgReceiveStrategy),
			0,      /* n_preallocs */
			tny_camel_partial_msg_receive_strategy_instance_init,    /* instance_init */
			NULL
		};


	static const GInterfaceInfo tny_msg_receive_strategy_info = 
		{
			(GInterfaceInitFunc) tny_msg_receive_strategy_init, /* interface_init */
			NULL,         /* interface_finalize */
			NULL          /* interface_data */
		};

	type = g_type_register_static (G_TYPE_OBJECT,
				       "TnyCamelPartialMsgReceiveStrategy",
				       &info, 0);
	
	g_type_add_interface_static (type, TNY_TYPE_MSG_RECEIVE_STRATEGY,
				     &tny_msg_receive_strategy_info);
	
	return GSIZE_TO_POINTER (type);
}
Пример #28
0
/* get a *list* of all messages with the given message id */
static GSList*
get_docids_from_msgids (MuQuery *query, const char *str, GError **err)
{
	gchar *querystr;
	MuMsgIter *iter;
	GSList *lst;

	querystr = g_strdup_printf ("msgid:%s", str);
	iter = mu_query_run (query, querystr, FALSE,
			     MU_MSG_FIELD_ID_NONE, FALSE,-1 /*unlimited*/,
			     err);
	g_free (querystr);

	if (!iter || mu_msg_iter_is_done (iter)) {
		mu_util_g_set_error (err, MU_ERROR_NO_MATCHES,
				     "could not find message %s", str);
		return NULL;
	}

	lst = NULL;
	do {
		lst = g_slist_prepend
			(lst,
			 GSIZE_TO_POINTER(mu_msg_iter_get_docid (iter)));
	} while (mu_msg_iter_next (iter));

	mu_msg_iter_destroy (iter);

	return lst;
}
Пример #29
0
/**
 * gwy_resource_class_load:
 * @klass: A resource class.
 *
 * Loads resources of a resources class from disk.
 *
 * Resources are loaded from system directory (and marked constant) and from
 * user directory (marked modifiable).
 **/
void
gwy_resource_class_load(GwyResourceClass *klass)
{
    gpointer type;
    gchar *path, *datadir;

    g_return_if_fail(GWY_IS_RESOURCE_CLASS(klass));
    g_return_if_fail(klass->inventory);

    gwy_inventory_forget_order(klass->inventory);

    type = GSIZE_TO_POINTER(G_TYPE_FROM_CLASS(klass));
    if (!g_slist_find(all_resources, type))
        all_resources = g_slist_prepend(all_resources, type);

    datadir = gwy_find_self_dir("data");
    path = g_build_filename(datadir, klass->name, NULL);
    g_free(datadir);
    gwy_resource_class_load_dir(path, klass, TRUE);
    g_free(path);

    path = g_build_filename(gwy_get_user_dir(), klass->name, NULL);
    gwy_resource_class_load_dir(path, klass, FALSE);
    g_free(path);

    gwy_inventory_restore_order(klass->inventory);
}
/* Block all unblocked signal handlers connect to signal ID in object instance.
 * Returns a list of all signal handlers block to get them unblocked again in
 * _interface_tweaks_unblock_handlers()
 */
static GSList* _interface_tweaks_block_all_handlers(GObject *inObject, guint inSignalID)
{
	gulong		handlerID;
	GSList		*blockedHandlers=NULL;

	/* Block unblocked signal handlers and keep a list of them */
	do
	{
		/* Find unblocked signal handler to signal ID in object instance.
		 * This will always the next one as the previous one has blocked
		 * or 0L if all signal handlers were blocked.
		 */
		handlerID=g_signal_handler_find(	inObject,
											G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_UNBLOCKED,
											inSignalID,
											0,
											NULL,
											NULL,
											NULL);

		/* Check if we found an unblocked signal handler */
		if(handlerID!=0L)
		{
			/* Add its signal handler ID to list to signal handlers blocked by us */
			blockedHandlers=g_slist_prepend(blockedHandlers, GSIZE_TO_POINTER(handlerID));

			/* Block signal */
			g_signal_handler_block(inObject, handlerID);
		}
	}
	while(handlerID!=0);

	/* Return list of block signal handlers */
	return(blockedHandlers);
}