void mm_modem_icera_simple_connect (MMModemIcera *self, GHashTable *properties) { MMModemIceraPrivate *priv = MM_MODEM_ICERA_GET_PRIVATE (self); g_free (priv->username); priv->username = g_strdup (get_string_property (properties, "username")); g_free (priv->password); priv->password = g_strdup (get_string_property (properties, "password")); }
tracked_object *tracked_object_create(const char *object_path) { // Allocate the memory tracked_object *tobj = g_malloc0(sizeof(tracked_object)); // Create the proxies tobj->device_proxy = dbus_g_proxy_new_for_name(dbus_conn, DBUS_COMMON_NAME_UDISKS, object_path, DBUS_INTERFACE_UDISKS_DEVICE); tobj->props_proxy = dbus_g_proxy_new_for_name(dbus_conn, DBUS_COMMON_NAME_UDISKS, object_path, DBUS_INTERFACE_DBUS_PROPERTIES); // Get the device file tobj->device_file = get_string_property(tobj->props_proxy, "DeviceFile", DBUS_INTERFACE_UDISKS_DEVICE); if (!tobj->device_file) { g_object_unref(tobj->device_proxy); g_object_unref(tobj->props_proxy); g_free(tobj); return NULL; } // Create a new cache tobj->props_cache = property_cache_create(); // Get a weak reference to the match object tobj->match_obj = matches_find_match(tobj->props_proxy, tobj->props_cache); tobj->match_obj_loaded = 1; return tobj; }
gchar *tracked_object_get_string_property(tracked_object *tobj, const char *name, int cached) { if (cached) return get_string_property_cached(tobj->props_cache, tobj->props_proxy, name, DBUS_INTERFACE_UDISKS_DEVICE); else return get_string_property(tobj->props_proxy, name, DBUS_INTERFACE_UDISKS_DEVICE); }
int main (int argc, char **argv) { int ret = EXIT_SUCCESS; Display *disp; Window root; char *newName; long pos = -1; int insert = 0; char *oldList; size_t oldLen; char *newList; size_t newLen; consume_arguments(argc, argv, &pos, &insert, &newName); disp = XOpenDisplay(NULL); if (disp == NULL) { fputs("Can't open display.\n", stderr); exit(EXIT_FAILURE); } root = DefaultRootWindow(disp); if (pos < 0) { pos = get_long_property(disp, root, "_NET_CURRENT_DESKTOP"); if (pos < 0) { fprintf(stderr, "Can't get _NET_CURRENT_DESKTOP.\n"); exit(EXIT_FAILURE); } } oldList = get_string_property(disp, root, "_NET_DESKTOP_NAMES", &oldLen); if (oldList == NULL) { fprintf(stderr, "Can't get _NET_DESKTOP_NAMES.\n"); exit(EXIT_FAILURE); } newList = add_name_to_list(oldList, oldLen, newName, pos, insert, &newLen); if (newList == NULL) { ret = EXIT_FAILURE; goto F1; } set_string_property(disp, root, "_NET_DESKTOP_NAMES", newList, newLen); XCloseDisplay(disp); free(newList); F1: free(oldList); exit(ret); }
gchar *get_string_property_cached(property_cache *cache, DBusGProxy *proxy, const char *name, const char *interface) { cache_value *value = g_hash_table_lookup(cache->entries, name); if (value) return value->values.string_value; gchar *res = get_string_property(proxy, name, interface); if (res) g_hash_table_insert(cache->entries, g_strdup(name), cache_value_create_string(res)); return res; }
static void handle_property(const XPropertyEvent *ev) { WClientWin *cwin; WClient *client; WScreen *scr; cwin=find_clientwin(ev->window); if(cwin==NULL) return; switch(ev->atom){ case XA_WM_NORMAL_HINTS: get_clientwin_size_hints(cwin); /*refit(cwin);*/ return; case XA_WM_NAME: /*if(cwin->name!=NULL) XFree((void*)cwin->name); cwin->name=get_string_property(cwin->win, XA_WM_NAME, NULL);*/ set_clientwin_name(cwin, get_string_property(cwin->win, XA_WM_NAME, NULL)); break; /*case XA_WM_ICON_NAME: if(cwin->icon_name!=NULL) XFree((void*)cwin->icon_name); cwin->icon_name=get_string_property(cwin->win, XA_WM_ICON_NAME, NULL); break;*/ case XA_WM_TRANSIENT_FOR: /*warn("Changes in WM_TRANSIENT_FOR property are unsupported.");*/ /*unmap_clientwin(cwin); manage_clientwin(ev->window, 0);*/ default: if(ev->atom==wglobal.atom_wm_protocols) get_protocols(cwin); return; } /*client=FIND_PARENT(cwin, WClient); if(client!=NULL) client_update_label(client);*/ }
/*================================================================================================== FUNCTION: Uart_get_driver_propertiess DESCRIPTION: ==================================================================================================*/ UartResult Uart_get_driver_properties( void ) { DALSYS_PROPERTY_HANDLE_DECLARE(hProp_driver); UART_LOG_0(INFO, "+Uart_get_driver_properties"); if( DAL_SUCCESS != DALSYS_GetDALPropertyHandleStr("/core/buses/uart",hProp_driver)) { UART_LOG_0(ERROR,"DALSYS_GetDALPropertyHandleStr for driver failed"); return UART_ERROR; } get_string_property(hProp_driver, "UartMainPortPhy", &uart_driver_props.device_names[UART_MAIN_PORT],NULL); UART_LOG_0(INFO, "-Uart_get_driver_properties"); return UART_SUCCESS; }
static int get_product_string(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDProductKey), buf, len); }
static int get_manufacturer_string(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDManufacturerKey), buf, len); }
static int get_serial_number(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDSerialNumberKey), buf, len); }
static int get_transport(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDTransportKey), buf, len); }
/*================================================================================================== FUNCTION: Uart_clock_open DESCRIPTION: ==================================================================================================*/ UartResult Uart_clock_open(UART_CONTEXT* h, uint32 input_freq) { DalDeviceHandle *dal_clock = NULL; DALResult result; uint32 result_freq = 0; char* clock_name = NULL; DALSYS_PROPERTY_HANDLE_DECLARE(hProp_device); UART_LOG_0(INFO, "+Uart_clock_open"); if (DAL_DeviceAttach(DALDEVICEID_CLOCK, &dal_clock) != DAL_SUCCESS) { UART_LOG_0(ERROR,"DALDEVICEID_CLOCK Attach failed"); return UART_ERROR; } h->clock_handle = (void*)dal_clock; if( DAL_SUCCESS != DALSYS_GetDALPropertyHandleStr(h->port_id, hProp_device)) { UART_LOG_0(ERROR,"DALSYS_GetDALPropertyHandleStr for device failed"); return UART_ERROR; } // Read the name of the Uart core clock get_string_property(hProp_device, "UartClockName", &clock_name, NULL); if (clock_name == NULL) { UART_LOG_0(ERROR, "UartClockname property not found."); return UART_ERROR; } // Look up the clock ID for the core clock result = DalClock_GetClockId(dal_clock, clock_name, (ClockIdType*)&h->properties.core_clock_id); if (result != DAL_SUCCESS) { UART_LOG_0(ERROR, "Core GetClockId failed."); return UART_ERROR; } // Read the name of the AHB clock get_string_property(hProp_device, "PClockName", &clock_name, NULL); if (result != DAL_SUCCESS || clock_name == NULL) { UART_LOG_0(ERROR, "PClockname property not found."); return UART_ERROR; } // Look up the clock ID for the AHB clock result = DalClock_GetClockId(dal_clock, clock_name, (ClockIdType*)&h->properties.bus_clock_id); if (result != DAL_SUCCESS) { UART_LOG_0(ERROR, "AHB GetClockId failed."); return UART_ERROR; } // Set the Frequency for the UART core clock. result = DalClock_SetClockFrequency( dal_clock, (ClockIdType)h->properties.core_clock_id, input_freq, CLOCK_FREQUENCY_HZ_EXACT, &result_freq); if (result != DAL_SUCCESS || result_freq != input_freq) { UART_LOG_0(ERROR, "DalClock_SetClockFrequency failed"); return UART_ERROR; } // Enable both the UART and AHB clocks result = DalClock_EnableClock(dal_clock, (ClockIdType)h->properties.core_clock_id); if (result != DAL_SUCCESS) { UART_LOG_0(ERROR, "Core clock - DalClock_EnableClock failed"); return UART_ERROR; } result = DalClock_EnableClock(dal_clock, (ClockIdType)h->properties.bus_clock_id); if (result != DAL_SUCCESS) { UART_LOG_0(ERROR, "Bus clock - DalClock_EnableClock failed"); return UART_ERROR; } UART_LOG_0(INFO, "-Uart_clock_open"); return UART_SUCCESS; }
guint probability __attribute__ ((unused)), const GstCaps *caps, gpointer data) { GstStructure *structure = NULL; AudioProperties *properties = NULL; const char *mpeg = NULL; properties = (AudioProperties *) data; structure = gst_caps_get_structure (caps, 0); /* MIMETYPE */ properties->mimetype = gst_structure_get_name (structure); mpeg = get_string_property(structure, "mpegversion"); if (mpeg != NULL) { properties->layer = get_string_property(structure, "layer"); properties->type = (gchar *) g_malloc0 (_GST_MALLOC_SIZE_); g_snprintf ((gpointer) properties->type, _GST_MALLOC_SIZE_, "MPEG%sV%s", mpeg, properties->layer); g_free ((gpointer) mpeg); } return TRUE; }
static gboolean check_origin_and_protocol (NPP instance) { gboolean ret = FALSE; NPError error; NPObject *window = NULL; NPVariant document = { NPVariantType_Void }; NPVariant location = { NPVariantType_Void }; gchar *hostname = NULL; gchar *protocol = NULL; error = funcs.getvalue (instance, NPNVWindowNPObject, &window); if (error != NPERR_NO_ERROR) goto out; if (!funcs.getproperty (instance, window, funcs.getstringidentifier ("document"), &document)) goto out; if (!NPVARIANT_IS_OBJECT (document)) goto out; if (!funcs.getproperty (instance, NPVARIANT_TO_OBJECT (document), funcs.getstringidentifier ("location"), &location)) goto out; if (!NPVARIANT_IS_OBJECT (location)) goto out; hostname = get_string_property (instance, NPVARIANT_TO_OBJECT (location), "hostname"); if (g_strcmp0 (hostname, ORIGIN)) { g_debug ("origin does not match, is %s", hostname); goto out; } protocol = get_string_property (instance, NPVARIANT_TO_OBJECT (location), "protocol"); if (g_strcmp0 (protocol, "https:") != 0) { g_debug ("protocol does not match, is %s", protocol); goto out; } ret = TRUE; out: g_free (protocol); g_free (hostname); funcs.releasevariantvalue (&location); funcs.releasevariantvalue (&document); if (window != NULL) funcs.releaseobject (window); return ret; }