Beispiel #1
0
int main(void) {
    preparation_t queries[] = {
        { "rate",
            "SELECT connectionStrength((select id from mode),$2,$1)" },
        { "getpage",
            "select strength,title,songs.id from connections inner join songs on connections.blue = songs.id where red = (select id from mode) order by strength desc OFFSET $1 LIMIT $2;" }
    };
    PQinit();
    gtk_init(NULL,NULL);
    prepareQueries(queries);

    GtkBuilder* builder = gtk_builder_new_from_string(gladeFile,gladeFileSize);
    GtkWidget* top = GTK_WIDGET(gtk_builder_get_object(builder,"top"));
    GtkTreeSelection* selection = GTK_TREE_SELECTION(
            gtk_builder_get_object(builder,"song-selection"));
    GtkButton* rateup = GTK_BUTTON(
            gtk_builder_get_object(builder,"rateup"));
    GtkButton* ratedown = GTK_BUTTON(
            gtk_builder_get_object(builder,"ratedown"));

    g_signal_connect(G_OBJECT(rateup),"clicked",G_CALLBACK(yay),selection);
    g_signal_connect(G_OBJECT(ratedown),"clicked",G_CALLBACK(nay),selection);

    GtkListStore* model = GTK_LIST_STORE(
            gtk_builder_get_object(builder,"songs"));

    fillNext(selection,model);
    gtk_widget_show_all(top);
    gtk_main();
}
void initializeDBLogger(const char * server, const char *user,
		const char * password, const char * database,
		DEALLOCATE_FUNC_POINTER func_p)
{
	EventProcessor = createEventProcessor(logInThread, cloneExceptionPointer,
			func_p);

	memset(ErrorStr, 0, sizeof(ErrorStr));

	if (createDatabaseConnection(server, user, password, database) == SUCCESS)
	{
		sprintf(ErrorStr, "DB connection created.");
	}
	else
	{
		sprintf(ErrorStr, "Failed to Create DB Connection. Error: %s",
				getString((char *) mysql_error(Conn)));
	}
	logError(ErrorStr);

	if (prepareQueries() == SUCCESS)
	{
		sprintf(ErrorStr, "Queries Prepared Successfully");
	}
	else
	{
		sprintf(ErrorStr, "Failed to Prepare Queries. Error: %s", getString(
				(char *) mysql_error(Conn)));
	}
	logError(ErrorStr);
}
Beispiel #3
0
int main (int argc, char ** argv)
{
  configInit();
  if(!declare_pid("player")) {
	puts("Player already found");
	return 1;
  }

  srandom(time(NULL));
  arguments = argv;
  signalsSetup();
  gst_init (NULL,NULL);
  selectSetup();
  onSignal(SIGUSR1,signalNext);
  onSignal(SIGUSR2,restartPlayer);

  preparation_t queries[] = {
    { "getTopRecording",
      "SELECT queue.recording,"
      "replaygain.gain,replaygain.peak,replaygain.level,"
      "recordings.path "
      "FROM queue INNER JOIN replaygain ON replaygain.id = queue.recording  INNER JOIN recordings ON recordings.id = queue.recording ORDER BY queue.id ASC LIMIT 1" },
  };
  prepareQueries(queries);

  GMainLoop* loop = g_main_loop_new (NULL, FALSE);
  void done_quit() {
	g_main_loop_quit(loop);
  }
Beispiel #4
0
void RemoteBlastHttpRequestTask::prepare() {
    prepareQueries();
    algoLog.trace("Sequences prepared");
    for (QList<Query>::iterator it = queries.begin(),end = queries.end();it!=end;it++) {
        DataBaseFactory *dbf = AppContext::getDataBaseRegistry()->getFactoryById(cfg.dbChoosen);
        if(dbf == NULL) {
            stateInfo.setError(tr("Incorrect database"));
            return;
        }
        HttpRequest *tmp = dbf->getRequest(this);
        httpRequest.append(tmp);
    }
    algoLog.trace("Requests formed");
    connect(&timer,SIGNAL(timeout()),SLOT(sl_timeout()));
    timeout = true;
    timer.setSingleShot(true);
    int mult = cfg.aminoT ? 6 : 1; //if 6 requests - 6 times more wait
    timer.start(cfg.retries*1000*60*mult);
}
ClientDAO::ClientDAO(IDatabase *pDB)
{
	db=pDB;
	prepareQueries();
}
void ClientDAO::restartQueries(void)
{
	destroyQueries();
	prepareQueries();
}