FolksIndividual * empathy_create_individual_from_tp_contact (TpContact *contact) { GeeSet *personas; TpfPersona *persona; FolksIndividual *individual; persona = tpf_persona_dup_for_contact (contact); if (persona == NULL) { DEBUG ("Failed to get a persona for %s", tp_contact_get_identifier (contact)); return NULL; } personas = GEE_SET ( gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref, g_direct_hash, g_direct_equal)); gee_collection_add (GEE_COLLECTION (personas), persona); individual = folks_individual_new (personas); g_clear_object (&persona); g_clear_object (&personas); return individual; }
static void link_individual (EmpathyIndividualLinker *self, FolksIndividual *individual) { EmpathyIndividualLinkerPriv *priv = GET_PRIV (self); GeeSet *old_personas, *new_personas; GeeHashSet *final_personas; gboolean personas_changed; /* Add the individual to the link */ g_hash_table_insert (priv->changed_individuals, individual, GUINT_TO_POINTER (TRUE)); /* Add personas which are in @individual to priv->new_individual, adding them * to the set of personas. */ old_personas = folks_individual_get_personas (individual); new_personas = folks_individual_get_personas (priv->new_individual); final_personas = gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref, g_direct_hash, g_direct_equal); gee_collection_add_all (GEE_COLLECTION (final_personas), GEE_COLLECTION (old_personas)); personas_changed = gee_collection_add_all (GEE_COLLECTION (final_personas), GEE_COLLECTION (new_personas)); /* avoid updating all values in the Individual if the set of personas doesn't * actually change */ if (personas_changed) { folks_individual_set_personas (priv->new_individual, GEE_SET (final_personas)); } g_clear_object (&final_personas); /* Update the toggle renderers, so that if this Individual is listed in * another group in the EmpathyIndividualView, the toggle button for that * group is updated. */ update_toggle_renderers (self); g_object_notify (G_OBJECT (self), "has-changed"); }
static void unlink_individual (EmpathyIndividualLinker *self, FolksIndividual *individual) { EmpathyIndividualLinkerPriv *priv = GET_PRIV (self); GeeSet *removed_personas, *old_personas; GeeHashSet *final_personas; gboolean personas_changed; /* Remove the individual from the link */ g_hash_table_remove (priv->changed_individuals, individual); /* Remove personas which are in @individual from priv->new_individual. */ old_personas = folks_individual_get_personas (priv->new_individual); removed_personas = folks_individual_get_personas (individual); final_personas = gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref, g_direct_hash, g_direct_equal); gee_collection_add_all (GEE_COLLECTION (final_personas), GEE_COLLECTION (old_personas)); personas_changed = gee_collection_remove_all (GEE_COLLECTION (final_personas), GEE_COLLECTION (removed_personas)); if (personas_changed) { folks_individual_set_personas (priv->new_individual, GEE_SET (final_personas)); } g_clear_object (&final_personas); /* Update the toggle renderers, so that if this Individual is listed in * another group in the EmpathyIndividualView, the toggle button for that * group is updated. */ update_toggle_renderers (self); g_object_notify (G_OBJECT (self), "has-changed"); }
void empathy_individual_manager_link_personas (EmpathyIndividualManager *self, GeeSet *personas) { EmpathyIndividualManagerPriv *priv; g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self)); g_return_if_fail (personas != NULL); priv = GET_PRIV (self); DEBUG ("Linking %u personas", gee_collection_get_size (GEE_COLLECTION (personas))); folks_individual_aggregator_link_personas (priv->aggregator, personas, (GAsyncReadyCallback) link_personas_cb, NULL); }
static FolksIndividual * create_individual_from_persona (FolksPersona *persona) { GeeSet *personas; FolksIndividual *individual; personas = GEE_SET ( gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL)); gee_collection_add (GEE_COLLECTION (personas), persona); individual = folks_individual_new (personas); g_clear_object (&personas); return individual; }
static void populate_data (EmpathyGroupsWidget *self) { EmpathyGroupsWidgetPriv *priv = GET_PRIV (self); EmpathyConnectionAggregator *aggregator; GeeSet *member_groups; GList *all_groups, *l; /* Remove the old groups */ gtk_list_store_clear (priv->group_store); /* FIXME: We have to get the whole group list from * EmpathyConnectionAggregator, as libfolks hasn't grown API to get the whole * group list yet. (bgo#627398) */ aggregator = empathy_connection_aggregator_dup_singleton (); all_groups = empathy_connection_aggregator_get_all_groups (aggregator); g_object_unref (aggregator); /* Get the list of groups that this #FolksGroupDetails is currently in */ member_groups = folks_group_details_get_groups (priv->group_details); for (l = all_groups; l != NULL; l = l->next) { const gchar *group_str = l->data; gboolean enabled; enabled = gee_collection_contains (GEE_COLLECTION (member_groups), group_str); gtk_list_store_insert_with_values (priv->group_store, NULL, -1, COL_NAME, group_str, COL_EDITABLE, TRUE, COL_ENABLED, enabled, -1); } g_list_free (all_groups); }
int main (int argc, char *argv[]) { RygelMediaServer *server; RygelSimpleContainer *root_container; char *path; GFile *source_dir; GFileEnumerator *enumerator; GFileInfo *info; int i; GMainLoop *loop; GError *error = NULL; // g_type_init (); rygel_media_engine_init (&error); if (error != NULL) { g_print ("Could not initialize media engine: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_set_application_name ("Standalone-Server"); root_container = rygel_simple_container_new_root ("Sample implementation"); if (argc >= 2) { path = g_strdup (argv[1]); } else { path = g_get_current_dir (); } source_dir = g_file_new_for_commandline_arg (path); g_free (path); enumerator = g_file_enumerate_children (source_dir, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); info = g_file_enumerator_next_file (enumerator, NULL, NULL); i = 0; while (info != NULL) { GFile *file; const char *display_name, *content_type; char *uri, *id; RygelMediaItem *item = NULL; GError *error = NULL; display_name = g_file_info_get_display_name (info); content_type = g_file_info_get_content_type (info); file = g_file_get_child_for_display_name (source_dir, display_name, &error); if (error != NULL) { g_critical ("Failed to get child: %s", error->message); return 127; } uri = g_file_get_uri (file); g_object_unref (file); id = g_strdup_printf ("%06d", i); if (g_str_has_prefix (content_type, "audio/")) { item = (RygelMediaItem*)rygel_audio_item_new (id, (RygelMediaContainer*)root_container, display_name, RYGEL_AUDIO_ITEM_UPNP_CLASS); } else if (g_str_has_prefix (content_type, "video/")) { item = (RygelMediaItem*)rygel_video_item_new (id, (RygelMediaContainer*)root_container, display_name, RYGEL_VIDEO_ITEM_UPNP_CLASS); } else if (g_str_has_prefix (content_type, "image/")) { item = (RygelMediaItem*)rygel_image_item_new (id, (RygelMediaContainer*)root_container, display_name, RYGEL_IMAGE_ITEM_UPNP_CLASS); } g_free (id); if (item != NULL) { RygelMediaObject *object; GeeArrayList* uris; rygel_media_item_set_mime_type (RYGEL_MEDIA_ITEM (item), content_type); object = RYGEL_MEDIA_OBJECT (item); gee_collection_add (GEE_COLLECTION (object->uris), uri); rygel_simple_container_add_child_item (root_container, item); } i++; info = g_file_enumerator_next_file (enumerator, NULL, NULL); } server = rygel_media_server_new ("Single purpose server", (RygelMediaContainer*)root_container, RYGEL_PLUGIN_CAPABILITIES_NONE); rygel_media_device_add_interface (RYGEL_MEDIA_DEVICE (server), "eth0"); rygel_media_device_add_interface (RYGEL_MEDIA_DEVICE (server), "wlan0"); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); }