コード例 #1
0
ファイル: async_queue.c プロジェクト: meh/glyr
void build_queries(GlyrQuery * one, GlyrQuery * two, GlyrQuery * three)
{
    glyr_query_init(one);
    glyr_query_init(two);
    glyr_query_init(three);

    glyr_opt_artist(one,"Diablo Swing Orchestra");
    glyr_opt_title (one,"Balrog Boogie");
    glyr_opt_type  (one, GLYR_GET_LYRICS);

    glyr_opt_artist(two, "Farin Urlaub");
    glyr_opt_download(two,FALSE);
    glyr_opt_type  (two, GLYR_GET_ARTIST_PHOTOS);

    glyr_opt_artist(three, "Knorkator");
    glyr_opt_type  (three, GLYR_GET_ARTIST_PHOTOS);
}
コード例 #2
0
static void moose_metadata_query_set_property(GObject *object,
                                              guint property_id,
                                              const GValue *value,
                                              GParamSpec *pspec) {
    MooseMetadataQueryPrivate *priv =
        moose_metadata_query_get_instance_private(MOOSE_METADATA_QUERY(object));

    switch(property_id) {
    case PROP_GET_TYPE:
        glyr_opt_type(&priv->query, glyr_string_to_get_type(g_value_get_string(value)));
        break;
    case PROP_ARTIST:
        glyr_opt_artist(&priv->query, g_value_get_string(value));
        break;
    case PROP_ALBUM:
        glyr_opt_album(&priv->query, g_value_get_string(value));
        break;
    case PROP_TITLE:
        glyr_opt_title(&priv->query, g_value_get_string(value));
        break;
    case PROP_DOWNLOAD:
        glyr_opt_download(&priv->query, g_value_get_boolean(value));
        break;
    case PROP_NUMBER:
        glyr_opt_number(&priv->query, g_value_get_int(value));
        break;
    case PROP_PROVIDERS:
        glyr_opt_from(&priv->query, g_value_get_string(value));
        break;
    case PROP_MUSIC_PATH:
        glyr_opt_from(&priv->query, g_value_get_string(value));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
        break;
    }
}
コード例 #3
0
ファイル: example.c プロジェクト: lejenome/glyr
int main(int argc, char *argv[])
{
    /* You need to call this before anything happens */
    glyr_init();
    atexit(glyr_cleanup);

    /* Initialize a new query (this may allocate memory) */
    GlyrQuery q;
    glyr_query_init(&q);

    /* Say we want a Songtext */
    GLYR_GET_TYPE type = GLYR_GET_LYRICS;
    glyr_opt_type(&q, type);

    /* Set at least the required fields to your needs        *
     * For lyrics those are 'artist' and 'title', ('album')  *
     * is strictly optional and may be used by a few plugins */
    glyr_opt_artist(&q, (char *) "Die Apokalyptischen Reiter");
    glyr_opt_album(&q, (char *) "Riders on the Storm");
    glyr_opt_title(&q, (char *) "Friede sei mit dir");

    /* Execute a func when getting one item */
    int this_be_my_counter = 0;
    glyr_opt_dlcallback(&q, funny_callback, &this_be_my_counter);

    /* For the start: Enable verbosity */
    glyr_opt_verbosity(&q, 2);

    /* Download 5 (or less) items */
    glyr_opt_number(&q, 5);

    /* Just search, without downloading items */
    glyr_opt_download(&q, 0);

    /* Call the most important command: GET!
     * This returned a list of (GlyrMemCache *)s
     * Each containing ONE item. (i.e. a songtext)
     */
    GLYR_ERROR err;
    GlyrMemCache *it = glyr_get(&q, &err, NULL);

    if(err != GLYRE_OK) {
        fprintf(stderr, "E:%s\n", glyr_strerror(err));
    }

    /* Now iterate through it... */
    if(it != NULL) {
        GlyrMemCache *start = it;

        int counter = 0;
        while(it != NULL) {
            /* This has the same effect as in the callback,
             * Just that it's executed just once after all DL is done.
             * Commented out, as this would print it twice
             * */
            print_item(it, counter);

            /* Every cache has a link to the next and prev one (or NULL respectively) */
            it = it->next;
            ++counter;
        }

        /* The contents of it are dynamically allocated. */
        /* So better free them if you're not keen on memoryleaks */
        glyr_free_list(start);
    }
    /* Destroy query (reset to default values and free dyn memory) */
    /* You could start right off to use this query in another glyr_get */
    glyr_query_destroy(&q);
    return EXIT_SUCCESS;
}