FCITX_EXPORT_API FcitxKbd* fcitx_kbd_new(GBusType bus_type, GDBusProxyFlags flags, gint display_number, GCancellable *cancellable, GError **error) { gchar servicename[64]; sprintf(servicename, "%s-%d", FCITX_DBUS_SERVICE, display_number); char* name = servicename; FcitxKbd* im = g_initable_new(FCITX_TYPE_KBD, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", "/keyboard", "g-interface-name", "org.fcitx.Fcitx.Keyboard", NULL); if (im != NULL) return FCITX_KBD(im); return NULL; }
/** * mm_modem_create_sms_sync: * @self: A #MMModemMessaging. * @properties: A ##MMSmsProperties object with the properties to use. * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL. * * Synchronously creates a new #MMSms in the modem. * * The calling thread is blocked until a reply is received. See mm_modem_messaging_create() * for the asynchronous version of this method. * * Returns: (transfer full): A newly created #MMSms, or %NULL if @error is set. The returned value should be freed with g_object_unref(). */ MMSms * mm_modem_messaging_create_sync (MMModemMessaging *self, MMSmsProperties *properties, GCancellable *cancellable, GError **error) { MMSms *sms = NULL; gchar *sms_path = NULL; GVariant *dictionary; g_return_val_if_fail (MM_IS_MODEM_MESSAGING (self), NULL); dictionary = (mm_sms_properties_get_dictionary (properties)); mm_gdbus_modem_messaging_call_create_sync (MM_GDBUS_MODEM_MESSAGING (self), dictionary, &sms_path, cancellable, error); if (sms_path) { sms = g_initable_new (MM_TYPE_SMS, cancellable, error, "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, "g-name", MM_DBUS_SERVICE, "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), "g-object-path", sms_path, "g-interface-name", "org.freedesktop.ModemManager1.Sms", NULL); g_free (sms_path); } g_variant_unref (dictionary); return (sms ? MM_SMS (sms) : NULL); }
/** * g_dbus_server_new_sync: * @address: A D-Bus address. * @flags: Flags from the #GDBusServerFlags enumeration. * @guid: A D-Bus GUID. * @observer: (allow-none): A #GDBusAuthObserver or %NULL. * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for server or %NULL. * * Creates a new D-Bus server that listens on the first address in * @address that works. * * Once constructed, you can use g_dbus_server_get_client_address() to * get a D-Bus address string that clients can use to connect. * * Connect to the #GDBusServer::new-connection signal to handle * incoming connections. * * The returned #GDBusServer isn't active - you have to start it with * g_dbus_server_start(). * * See <xref linkend="gdbus-peer-to-peer"/> for how #GDBusServer can * be used. * * This is a synchronous failable constructor. See * g_dbus_server_new() for the asynchronous version. * * Returns: A #GDBusServer or %NULL if @error is set. Free with * g_object_unref(). * * Since: 2.26 */ GDBusServer * g_dbus_server_new_sync (const gchar *address, GDBusServerFlags flags, const gchar *guid, GDBusAuthObserver *observer, GCancellable *cancellable, GError **error) { GDBusServer *server; g_return_val_if_fail (address != NULL, NULL); g_return_val_if_fail (g_dbus_is_guid (guid), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); server = g_initable_new (G_TYPE_DBUS_SERVER, cancellable, error, "address", address, "flags", flags, "guid", guid, "authentication-observer", observer, NULL); return server; }
/** * uca_plugin_manager_get_camera: (skip) * @manager: A #UcaPluginManager * @name: Name of the camera module, that maps to libuca<name>.so * @error: Location for a #GError * @first_prop_name: (allow-none): name of the first property, or %NULL if no * properties * @...: value of the first property, followed by and other property value * pairs, and ended by %NULL. * * Create a new camera instance with camera @name. * * Returns: (transfer full): A new #UcaCamera object. * Since: 1.2: Pass construction properties. */ UcaCamera * uca_plugin_manager_get_camera (UcaPluginManager *manager, const gchar *name, GError **error, const gchar *first_prop_name, ...) { UcaPluginManagerPrivate *priv; UcaCamera *camera; GType type; va_list var_args; g_return_val_if_fail (UCA_IS_PLUGIN_MANAGER (manager) && (name != NULL), NULL); priv = manager->priv; type = get_camera_type (priv, name, error); if (type == G_TYPE_NONE) return NULL; va_start (var_args, first_prop_name); camera = (UcaCamera *) g_initable_new (type, NULL, error, first_prop_name, var_args); va_end (var_args); return camera; }
bool ArgumentCoder<CertificateInfo>::decode(ArgumentDecoder& decoder, CertificateInfo& certificateInfo) { bool hasCertificate; if (!decoder.decode(hasCertificate)) return false; if (!hasCertificate) return true; IPC::DataReference certificateDataReference; if (!decoder.decodeVariableLengthByteArray(certificateDataReference)) return false; GByteArray* certificateData = g_byte_array_sized_new(certificateDataReference.size()); certificateData = g_byte_array_append(certificateData, certificateDataReference.data(), certificateDataReference.size()); GRefPtr<GByteArray> certificateBytes = adoptGRef(certificateData); GTlsBackend* backend = g_tls_backend_get_default(); GRefPtr<GTlsCertificate> certificate = adoptGRef(G_TLS_CERTIFICATE(g_initable_new( g_tls_backend_get_certificate_type(backend), 0, 0, "certificate", certificateBytes.get(), nullptr))); certificateInfo.setCertificate(certificate.get()); uint32_t tlsErrors; if (!decoder.decode(tlsErrors)) return false; certificateInfo.setTLSErrors(static_cast<GTlsCertificateFlags>(tlsErrors)); return true; }
GObject * hev_iobj_new (GCancellable *cancellable, GError **error) { g_debug ("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); return g_initable_new (HEV_TYPE_IOBJ, cancellable, error, NULL); }
static gboolean create_loopback_context (gpointer data) { GUPnPNetworkManager *manager = (GUPnPNetworkManager *) data; GUPnPContext *context; guint port; GError *error = NULL; manager->priv->idle_context_creation_src = NULL; g_object_get (manager, "port", &port, NULL); context = g_initable_new (GUPNP_TYPE_CONTEXT, NULL, &error, "interface", LOOPBACK_IFACE, "port", port, NULL); if (error) { g_warning ("Error creating GUPnP context: %s\n", error->message); g_error_free (error); return FALSE; } g_signal_emit_by_name (manager, "context-available", context); g_object_unref (context); return FALSE; }
static void create_context_for_device (NMDevice *nm_device) { GError *error = NULL; guint port; GVariant *value; char *iface; char *ssid = NULL; g_object_get (nm_device->manager, "port", &port, NULL); value = g_dbus_proxy_get_cached_property (nm_device->proxy, "Interface"); if (G_UNLIKELY (value == NULL)) return; if (G_UNLIKELY (!g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))) { g_variant_unref (value); return; } iface = g_variant_dup_string (value, NULL); g_variant_unref (value); if (nm_device->ap_proxy != NULL) { value = g_dbus_proxy_get_cached_property (nm_device->ap_proxy, "Ssid"); if (G_LIKELY (value != NULL)) { ssid = g_strndup (g_variant_get_data (value), g_variant_get_size (value)); g_variant_unref (value); } } nm_device->context = g_initable_new (GUPNP_TYPE_CONTEXT, NULL, &error, "interface", iface, "network", ssid, "port", port, NULL); g_free (iface); g_free (ssid); if (error) { g_warning ("Error creating GUPnP context: %s\n", error->message); g_error_free (error); return; } g_signal_emit_by_name (nm_device->manager, "context-available", nm_device->context); }
GDBusProxy * _nm_dbus_new_proxy_for_connection (GDBusConnection *connection, const char *path, const char *interface, GCancellable *cancellable, GError **error) { GDBusProxy *proxy; GType proxy_type; const char *name; proxy_type = GPOINTER_TO_SIZE (g_hash_table_lookup (proxy_types, interface)); if (!proxy_type) proxy_type = G_TYPE_DBUS_PROXY; if (_nm_dbus_is_connection_private (connection)) name = NULL; else name = NM_DBUS_SERVICE; proxy = g_initable_new (proxy_type, cancellable, error, "g-connection", connection, "g-flags", NM_DBUS_PROXY_FLAGS, "g-name", name, "g-object-path", path, "g-interface-name", interface, NULL); _nm_dbus_proxy_replace_match (proxy); return proxy; }
GTlsDatabaseOpenssl * g_tls_database_openssl_new (GError **error) { g_return_val_if_fail (!error || !*error, NULL); return g_initable_new (G_TYPE_TLS_DATABASE_OPENSSL, NULL, error, NULL); }
/** * nm_secret_agent_simple_new: * @name: the identifier of secret agent * * Creates a new #NMSecretAgentSimple. It does not serve any requests until * nm_secret_agent_simple_enable() is called. * * Returns: a new #NMSecretAgentSimple if the agent creation is successful * or %NULL in case of a failure. */ NMSecretAgentOld * nm_secret_agent_simple_new (const char *name) { return g_initable_new (NM_TYPE_SECRET_AGENT_SIMPLE, NULL, NULL, NM_SECRET_AGENT_OLD_IDENTIFIER, name, NULL); }
SecretPrompt * _secret_prompt_instance (SecretService *service, const gchar *prompt_path) { GDBusProxy *proxy; SecretPrompt *prompt; GError *error = NULL; g_return_val_if_fail (SECRET_IS_SERVICE (service), NULL); g_return_val_if_fail (prompt_path != NULL, NULL); proxy = G_DBUS_PROXY (service); prompt = g_initable_new (SECRET_TYPE_PROMPT, NULL, &error, "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, "g-interface-info", _secret_gen_prompt_interface_info (), "g-name", g_dbus_proxy_get_name (proxy), "g-connection", g_dbus_proxy_get_connection (proxy), "g-object-path", prompt_path, "g-interface-name", SECRET_PROMPT_INTERFACE, NULL); if (error != NULL) { g_warning ("couldn't create SecretPrompt object: %s", error->message); g_clear_error (&error); return NULL; } return prompt; }
static gboolean service_context_create (CMService *cm_service) { GError *error = NULL; cm_service->context = g_initable_new (GUPNP_TYPE_CONTEXT, NULL, &error, "interface", cm_service->iface, "network", cm_service->name, "port", cm_service->port, NULL); if (error != NULL) { g_warning ("Error creating GUPnP context: %s", error->message); g_error_free (error); return FALSE; } g_signal_emit_by_name (cm_service->manager, "context-available", cm_service->context); return TRUE; }
/** * mm_modem_voice_create_call_sync: * @self: A #MMModemVoice. * @properties: A ##MMCallProperties object with the properties to use. * @cancellable: (allow-none): A #GCancellable or %NULL. * @error: Return location for error or %NULL. * * Synchronously creates a new #MMCall in the modem. * * The calling thread is blocked until a reply is received. See mm_modem_voice_create_call() * for the asynchronous version of this method. * * Returns: (transfer full): A newly created #MMCall, or %NULL if @error is set. The returned value should be freed with g_object_unref(). */ MMCall * mm_modem_voice_create_call_sync (MMModemVoice *self, MMCallProperties *properties, GCancellable *cancellable, GError **error) { MMCall *call = NULL; gchar *call_path = NULL; GVariant *dictionary; g_return_val_if_fail (MM_IS_MODEM_VOICE (self), NULL); dictionary = mm_call_properties_get_dictionary (properties); mm_gdbus_modem_voice_call_create_call_sync (MM_GDBUS_MODEM_VOICE (self), dictionary, &call_path, cancellable, error); if (call_path) { call = g_initable_new (MM_TYPE_CALL, cancellable, error, "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, "g-name", MM_DBUS_SERVICE, "g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)), "g-object-path", call_path, "g-interface-name", "org.freedesktop.ModemManager1.Call", NULL); g_free (call_path); } g_variant_unref (dictionary); return (call ? MM_CALL (call) : NULL); }
bool Coder<WebCore::CertificateInfo>::decode(Decoder& decoder, WebCore::CertificateInfo& certificateInfo) { bool hasCertificate; if (!decoder.decode(hasCertificate)) return false; if (!hasCertificate) return true; uint64_t size = 0; if (!decoder.decode(size)) return false; Vector<uint8_t> vector(size); if (!decoder.decodeFixedLengthData(vector.data(), vector.size())) return false; GByteArray* certificateData = g_byte_array_sized_new(vector.size()); certificateData = g_byte_array_append(certificateData, vector.data(), vector.size()); GRefPtr<GByteArray> certificateBytes = adoptGRef(certificateData); GTlsBackend* backend = g_tls_backend_get_default(); GRefPtr<GTlsCertificate> certificate = adoptGRef(G_TLS_CERTIFICATE(g_initable_new( g_tls_backend_get_certificate_type(backend), 0, 0, "certificate", certificateBytes.get(), nullptr))); certificateInfo.setCertificate(certificate.get()); uint32_t tlsErrors; if (!decoder.decode(tlsErrors)) return false; certificateInfo.setTLSErrors(static_cast<GTlsCertificateFlags>(tlsErrors)); return true; }
int main (G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) { GError *error; GUPnPContext *context; GUPnPControlPoint *cp; #ifndef G_OS_WIN32 struct sigaction sig_action; #endif /* G_OS_WIN32 */ #if !GLIB_CHECK_VERSION(2,35,0) g_type_init (); #endif setlocale (LC_ALL, ""); error = NULL; context = g_initable_new (GUPNP_TYPE_CONTEXT, NULL, &error, NULL); if (error) { g_printerr ("Error creating the GUPnP context: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } /* We're interested in everything */ cp = gupnp_control_point_new (context, "urn:schemas-upnp-org:service:ContentDirectory:1"); g_signal_connect (cp, "service-proxy-available", G_CALLBACK (service_proxy_available_cb), NULL); g_signal_connect (cp, "service-proxy-unavailable", G_CALLBACK (service_proxy_unavailable_cb), NULL); gssdp_resource_browser_set_active (GSSDP_RESOURCE_BROWSER (cp), TRUE); main_loop = g_main_loop_new (NULL, FALSE); /* Hook the handler for SIGTERM */ #ifndef G_OS_WIN32 memset (&sig_action, 0, sizeof (sig_action)); sig_action.sa_handler = interrupt_signal_handler; sigaction (SIGINT, &sig_action, NULL); #else signal(SIGINT,interrupt_signal_handler); #endif /* G_OS_WIN32 */ g_main_loop_run (main_loop); g_main_loop_unref (main_loop); g_object_unref (cp); g_object_unref (context); return EXIT_SUCCESS; }
/** * facq_plethysmograph_new: * @address: The listen address. * @port: The port. * @err: A #GError, it will be set in case of error if not %NULL. * * Creates a new #FacqPlethysmograph object, that listens for connection * petitions on the address, @address, and port, @port. (See #FacqPlug for more * details about valid values). * * Returns: A new #FacqPlethysmograph object or %NULL in case of error. */ FacqPlethysmograph *facq_plethysmograph_new(const gchar *address,guint16 port,GError **err) { return FACQ_PLETHYSMOGRAPH(g_initable_new(FACQ_TYPE_PLETHYSMOGRAPH, NULL,err, "address",address, "port",port, NULL)); }
MMPluginManager * mm_plugin_manager_new (GError **error) { return g_initable_new (MM_TYPE_PLUGIN_MANAGER, NULL, error, NULL); }
/** * ufo_resources_new: * @config: A #UfoConfiguration object or %NULL * @error: Location of a #GError or %NULL * * Create a new #UfoResources instance. * * Returns: (transfer none): A new #UfoResources */ UfoResources * ufo_resources_new (UfoConfig *config, GError **error) { return g_initable_new (UFO_TYPE_RESOURCES, NULL, error, "config", config, NULL); }
/** * facq_oscope_new: * @address: The default ip address. * @port: The default port to listen on. * @err: A #GError it will be set in case of error if not %NULL. * * Creates a new #FacqOscope object that will listen for connections * on @address:@port. * * Returns: A new #FacqOscope object. */ FacqOscope *facq_oscope_new(const gchar *address,guint16 port,GError **err) { return FACQ_OSCOPE(g_initable_new(FACQ_TYPE_OSCOPE, NULL,err, "address",address, "port",port, NULL)); }
/** * gsound_context_new: * @cancellable: (allow-none): A #GCancellable, or %NULL * @error: Return location for error * * Returns: (transfer full): A new #GSoundContext */ GSoundContext * gsound_context_new(GCancellable *cancellable, GError **error) { return GSOUND_CONTEXT(g_initable_new(GSOUND_TYPE_CONTEXT, cancellable, error, NULL)); }
/** * hs_ext_new: * * Try to initialize #HsExt. * * Returns: the pointer of #HsExt if initalized successfully */ HsExt * hs_ext_new (void) { static HsExt * instance = NULL; if (!instance) instance = HS_EXT (g_initable_new (HS_TYPE_EXT, NULL, NULL, NULL)); return instance; }
TrackerController * tracker_controller_new (guint shutdown_timeout, GError **error) { return g_initable_new (TRACKER_TYPE_CONTROLLER, NULL, error, "shutdown-timeout", shutdown_timeout, NULL); }
int main (int argc, char **argv) { LOGD("========================================================="); LOGD(" START TEST-PUBLISH"); LOGD("========================================================="); GSSDPClient *client; GSSDPResourceGroup *resource_group; GError *error; GMainLoop *main_loop; //g_type_init (); error = NULL; client = g_initable_new (GSSDP_TYPE_CLIENT, NULL, &error, NULL); if (error) { //g_printerr ("Error creating the GSSDP client: %s\n", error->message); LOGD("Error creating the GSSDP client: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } resource_group = gssdp_resource_group_new (client); LOGD("========================================================="); LOGD(" add resource"); LOGD("========================================================="); gssdp_resource_group_add_resource_simple (resource_group, "upnp:rootdevice", "uuid:1234abcd-12ab-12ab-12ab-1234567abc12::upnp:rootdevice", "http://192.168.1.100/"); gssdp_resource_group_set_available (resource_group, TRUE); LOGD("========================================================="); LOGD(" set loop"); LOGD("========================================================="); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); g_main_loop_unref (main_loop); g_object_unref (resource_group); g_object_unref (client); return EXIT_SUCCESS; }
/** * facq_log_window_new: * @top_window: The toplevel #GtkWindow of your application. * @filename: The name of the file where #FacqLog is logging messages. * @lines: The number of lines you want to show to the user, between 1 and * 10000, if you don't know what value to use here use 30. * @err: A #GError, it will be set in case of error if not %NULL. * * Creates a new #FacqLogWindow object, and shows the log window. * Note that the window content will auto-update as long as new text arrives * the log. * * Returns: A new #FacqLogWindow object. */ FacqLogWindow *facq_log_window_new(GtkWidget *top_window,const gchar *filename,guint lines,GError **err) { return g_initable_new(FACQ_TYPE_LOG_WINDOW, NULL,err, "top-window",top_window, "filename",filename, "lines",lines, NULL); }
EekLayout * eek_xml_layout_new (const gchar *id, GError **error) { return (EekLayout *) g_initable_new (EEK_TYPE_XML_LAYOUT, NULL, error, "id", id, NULL); }
int main (int argc, char **argv) { GError *error = NULL; GUPnPContext *context; GUPnPControlPoint *cp; #ifndef G_OS_WIN32 struct sigaction sig_action; #endif /* G_OS_WIN32 */ error = NULL; context = g_initable_new (GUPNP_TYPE_CONTEXT, NULL, &error, NULL); if (error) { g_printerr ("Error creating the GUPnP context: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } cancellable = g_cancellable_new (); /* We're interested in everything */ cp = gupnp_control_point_new (context, "ssdp:all"); g_signal_connect (cp, "service-proxy-available", G_CALLBACK (service_proxy_available_cb), NULL); g_signal_connect (cp, "service-proxy-unavailable", G_CALLBACK (service_proxy_unavailable_cb), NULL); gssdp_resource_browser_set_active (GSSDP_RESOURCE_BROWSER (cp), TRUE); main_loop = g_main_loop_new (NULL, FALSE); /* Hook the handler for SIGTERM */ #ifndef G_OS_WIN32 memset (&sig_action, 0, sizeof (sig_action)); sig_action.sa_handler = interrupt_signal_handler; sigaction (SIGINT, &sig_action, NULL); #else signal(SIGINT,interrupt_signal_handler); #endif /* G_OS_WIN32 */ g_main_loop_run (main_loop); g_main_loop_unref (main_loop); g_object_unref (cp); g_object_unref (context); return EXIT_SUCCESS; }
TrackerMiner * tracker_miner_applications_new (GError **error) { return g_initable_new (TRACKER_TYPE_MINER_APPLICATIONS, NULL, error, "name", "Applications", "processing-pool-wait-limit", 10, "processing-pool-ready-limit", 100, NULL); }
SpiceNamedPipe* spice_win32_user_pipe_new (gchar *name, GError **error) { SECURITY_ATTRIBUTES sa; SECURITY_DESCRIPTOR sd; PACL dacl = NULL; HANDLE pipe; SpiceNamedPipe *np = NULL; g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (error != NULL, NULL); if (!get_user_security_attributes (&sa, &sd, &dacl)) return NULL; pipe = CreateNamedPipe (name, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | /* FIXME: why is FILE_FLAG_FIRST_PIPE_INSTANCE needed for WRITE_DAC * (apparently needed by SetSecurityInfo). This will prevent * multiple pipe listener....?! */ FILE_FLAG_FIRST_PIPE_INSTANCE | WRITE_DAC, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, DEFAULT_PIPE_BUF_SIZE, DEFAULT_PIPE_BUF_SIZE, 0, &sa); if (pipe == INVALID_HANDLE_VALUE) { int errsv = GetLastError (); gchar *emsg = g_win32_error_message (errsv); g_set_error (error, G_IO_ERROR, g_io_error_from_win32_error (errsv), "Error CreateNamedPipe(): %s", emsg); g_free (emsg); goto end; } /* lower integrity on Vista/Win7+ */ if ((LOBYTE (g_win32_get_windows_version()) > 0x05 || LOWORD (g_win32_get_windows_version()) > 0x0105) && !spice_win32_set_low_integrity (pipe, error)) goto end; np = SPICE_NAMED_PIPE (g_initable_new (SPICE_TYPE_NAMED_PIPE, NULL, error, "handle", pipe, NULL)); end: LocalFree (dacl); return np; }
/** * fep_g_client_new: * @address: (allow-none): socket address of the FEP server * @cancellable: a #GCancellable or %NULL * @error: a pointer to a NULL #GError, or %NULL * * Connect to the FEP server running at @address. If @address is * %NULL, it gets the address from the environment variable * `LIBFEP_CONTROL_SOCK`. * * Returns: a new #FepGClient. */ FepGClient * fep_g_client_new (const char *address, GCancellable *cancellable, GError **error) { return g_initable_new (FEP_TYPE_G_CLIENT, cancellable, error, "address", address, NULL); }