int main(int argc, char *argv[]) {
    srand((int)time(NULL));
    address_initialization();
    account_register_toBank();
    int balance = eCent_balance();
    if (balance == 0) {
        printf("Balance is equal to 0, get 50 from the bank.\n");
        eCent_get(50);
    }else {
        printf("eCent Balance: %d\n", balance);
    }
    int available_result = list_available();
    if (available_result != 0) {
        return 1;
    }
    //generate the data.
    char rand_data[DATA_LENGTH+1];
    rand_data[0] = '\0';
    random_data(rand_data);
    //before the final step start, call the bank to transfer the eCent.
    int transfer_result = eCent_transfer_toAnalysis();
    if (transfer_result != 0) {
        return transfer_result;
    }
    int analysis_result = request_analysis(rand_data);
    if (analysis_result != 0)
    {
        return analysis_result;
    }
    return 0;
}
Ejemplo n.º 2
0
void
samplecat_list_store_add (SamplecatListStore* self, Sample* sample)
{

	if(!samplecat.store) return;
	g_return_if_fail(sample);

#if 1
	/* these has actualy been checked _before_ here
	 * but backend may 'inject' mime types. ?!
	 */
	if(!sample->mimetype){
		dbg(0,"no mimetype given -- this should NOT happen: fix backend");
		return;
	}
	if(mimestring_is_unsupported(sample->mimetype)){
		dbg(0, "unsupported MIME type: %s", sample->mimetype);
		return;
	}
#endif

	if(!sample->sample_rate){
		// needed w/ tracker backend.
		sample_get_file_info(sample);
	}

	char samplerate_s[32]; samplerate_format(samplerate_s, sample->sample_rate);
	char length_s[64]; format_smpte(length_s, sample->length);

#ifdef USE_AYYI
	GdkPixbuf* ayyi_icon = NULL;

	//is the file loaded in the current Ayyi song?
	if(ayyi.got_shm){
		gchar* fullpath = g_build_filename(sample->sample_dir, sample->name, NULL);
		if(ayyi_song__have_file(fullpath)){
			dbg(1, "sample is used in current project TODO set icon");
		} else dbg(2, "sample not used in current project");
		g_free(fullpath);
	}
#endif

#define NSTR(X) (X?X:"")

	//icon (only shown if the sound file is currently available)
	GdkPixbuf* iconbuf = sample->online ? get_iconbuf_from_mimetype(sample->mimetype) : NULL;

	GtkTreeIter iter;
	gtk_list_store_append(samplecat.store, &iter);
	gtk_list_store_set(samplecat.store, &iter,
			COL_ICON,       iconbuf,
			COL_NAME,       sample->name,
			COL_FNAME,      sample->sample_dir,
			COL_IDX,        sample->id,
			COL_MIMETYPE,   sample->mimetype,
			COL_KEYWORDS,   NSTR(sample->keywords),
			COL_PEAKLEVEL,  sample->peaklevel,
			COL_OVERVIEW,   sample->overview,
			COL_LENGTH,     length_s,
			COL_SAMPLERATE, samplerate_s,
			COL_CHANNELS,   sample->channels,
			COL_COLOUR,     sample->colour_index,
#ifdef USE_AYYI
			COL_AYYI_ICON,  ayyi_icon,
#endif
			COL_SAMPLEPTR,  sample,
			COL_LEN,        sample->length,
			-1);

	GtkTreePath* treepath;
	if((treepath = gtk_tree_model_get_path(GTK_TREE_MODEL(samplecat.store), &iter))){
		sample->row_ref = gtk_tree_row_reference_new(GTK_TREE_MODEL(samplecat.store), treepath);
		gtk_tree_path_free(treepath);
	}

	g_return_if_fail (self);
	if(sample->row_ref && sample->online){
		request_analysis(sample);
	}

	sample_ref (sample);
}