Exemplo n.º 1
0
DatePickerClient::DatePickerClient(BlackBerry::Platform::BlackBerryInputType type, const BlackBerry::Platform::String& value, const BlackBerry::Platform::String& min, const BlackBerry::Platform::String& max, double step, BlackBerry::WebKit::WebPagePrivate* webPage, HTMLInputElement* element)
    : m_type(type)
    , m_webPage(webPage)
    , m_element(element)
{
    generateHTML(type, value, min, max, step);
}
Exemplo n.º 2
0
bool PagePopupBlackBerry::init(WebPage* webpage)
{
    generateHTML(webpage);

    installDOMFunction(webpage->d->mainFrame());

    return true;
}
Exemplo n.º 3
0
void SelectPopupClient::update(bool multiple, int size, const ScopeArray<BlackBerry::Platform::String>& labels, bool* enableds,
    const int* itemType, bool* selecteds, BlackBerry::WebKit::WebPagePrivate*, HTMLSelectElement* element)
{
    m_multiple = multiple;
    m_size = size;
    m_element = element;
    generateHTML(multiple, size, labels, enableds, itemType, selecteds);
}
Exemplo n.º 4
0
SelectPopupClient::SelectPopupClient(bool multiple, int size, const ScopeArray<BlackBerry::WebKit::WebString>& labels, bool* enableds,
    const int* itemType, bool* selecteds, BlackBerry::WebKit::WebPagePrivate* webPage, HTMLSelectElement* element)
    : m_multiple(multiple)
    , m_size(size)
    , m_webPage(webPage)
    , m_element(element)
{
    generateHTML(multiple, size, labels, enableds, itemType, selecteds);
}
Exemplo n.º 5
0
int main()
{
	addLog("===========================================================");
	addLog("NWChecker started");
	string curdir=getCurrentDir();
	loadResults();
	if (parseConfig())
		return 1;
	checkAll();
	SetCurrentDirectory(curdir.c_str());
	generateHTML();
	saveResults();
	if(silentMode) {
		int i;
		cin>>i;
	}
	return 0;
}
Exemplo n.º 6
0
bool ExportHelper::exportHTML(const int qryheadid, ParameterList &params, QString &filename, QString &errmsg)
{
  if (DEBUG)
    qDebug("ExportHelper::exportHTML(%d, %d params, %s, errmsg) entered",
           qryheadid, params.size(), qPrintable(filename));
  bool returnVal = false;

  XSqlQuery setq;
  setq.prepare("SELECT * FROM qryhead WHERE qryhead_id=:id;");
  setq.bindValue(":id", qryheadid);
  setq.exec();
  if (setq.first())
  {
    if (filename.isEmpty())
    {
      QFileInfo fileinfo(setq.value("qryhead_name").toString());
      filename = fileinfo.absoluteFilePath();
    }

    QFile *exportfile = new QFile(filename);
    if (! exportfile->open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text))
      errmsg = tr("Could not open %1: %2.")
                                      .arg(filename, exportfile->errorString());
    else
    {
      if (exportfile->write(generateHTML(qryheadid, params, errmsg).toUtf8()) < 0)
        errmsg = tr("Error writing to %1: %2")
                                      .arg(filename, exportfile->errorString());
      exportfile->close();
    }
  }
  else if (setq.lastError().type() != QSqlError::NoError)
    errmsg = setq.lastError().text();
  else
    errmsg = tr("<p>Cannot export data because the query set with "
                "id %1 was not found.").arg(qryheadid);

  if (DEBUG)
    qDebug("ExportHelper::exportHTML returning %d, filename %s, and errmsg %s",
           returnVal, qPrintable(filename), qPrintable(errmsg));

  return returnVal;
}
Exemplo n.º 7
0
QString ExportHelper::generateHTML(const int qryheadid, ParameterList &params, QString &errmsg)
{
  if (DEBUG)
    qDebug("ExportHelper::generateHTML(%d, %d params, errmsg) entered",
           qryheadid, params.size());
  QTextDocument doc(0);
  QTextCursor   cursor(&doc);

  XSqlQuery itemq;
  itemq.prepare("SELECT * FROM qryitem WHERE qryitem_qryhead_id=:id ORDER BY qryitem_order;");
  itemq.bindValue(":id", qryheadid);
  itemq.exec();
  while (itemq.next())
  {
    QString qtext;
    if (itemq.value("qryitem_src").toString() == "REL")
    {
      QString schemaName = itemq.value("qryitem_group").toString();
      qtext = "SELECT * FROM " +
              (schemaName.isEmpty() ? QString("") : schemaName + QString(".")) +
              itemq.value("qryitem_detail").toString();
    }
    else if (itemq.value("qryitem_src").toString() == "MQL")
    {
      QString tmpmsg;
      bool valid;
      qtext = MQLUtil::mqlLoad(itemq.value("qryitem_group").toString(),
                               itemq.value("qryitem_detail").toString(),
                               tmpmsg, &valid);
      if (! valid)
        errmsg = tmpmsg;
    }
    else if (itemq.value("qryitem_src").toString() == "CUSTOM")
      qtext = itemq.value("qryitem_detail").toString();

    if (! qtext.isEmpty())
      cursor.insertHtml(generateHTML(qtext, params, errmsg));
  }
  if (itemq.lastError().type() != QSqlError::NoError)
    errmsg = itemq.lastError().text();

  return doc.toHtml();
}
Exemplo n.º 8
0
void generatePuzzle()
{
	printf("Generating Puzzle:\n");
	
	size_t keyCount = 0;
	size_t targetCount = 0;
	int i = 0;
	
	// Get current image count in database
	redisReply *getReply = redisCommand(Context, "SCARD %s", GRP_TARGET_NAME);
	keyCount = getReply->integer;
	freeReplyObject(getReply);
	
	// Check if there is right amount of images
	if (keyCount >= MIN_IMAGE_TYPES) {
		
		/*
		 * Get background
		 */
		// Get background size
		redisReply *backgroundSize = redisCommand(Context, "SCARD %s", GRP_BACKGROUND_NAME);
		
		char backgroundNumber[4];
		char backgroundFileName[64];
		int randomBackgroundNumber = 1;
		
		targetCount = backgroundSize->integer;
		
		if (randomBackgroundNumber != (int)targetCount) {
			randomBackgroundNumber = generateRandomNumber(1, (int)backgroundSize->integer);
		}
		
		snprintf(backgroundNumber, 4, "%d", randomBackgroundNumber);
		strcpy(backgroundFileName, "");
		strcat(backgroundFileName, BackgroundDIR);
		strcat(backgroundFileName, "/");
		strcat(backgroundFileName, BackgroundDIR);
		strcat(backgroundFileName, backgroundNumber);
		strcat(backgroundFileName, ".jpg");
		
		printf("\nPicked %s%s as background\n", BackgroundDIR, backgroundNumber);
		
		freeReplyObject(backgroundSize);
		
		// Get a background image
		gdImagePtr background = loadImage(backgroundFileName, ".jpg");
		
		if (background == NULL) {
			// Exit out
			printf("Error opening background image\n");
			return;
		}
		
		int randomArray[MIN_IMAGE_TYPES] = {0, 0, 0, 0, 0};
		generateRandomTargetGroups(1, MIN_IMAGE_TYPES, randomArray);
		
		redisReply *targetList = redisCommand(Context, "SMEMBERS %s", GRP_TARGET_NAME);
		
		printf("\nPicked targets Below:\n");
		
		for (i = 0; i < MIN_IMAGE_TYPES; i++) {
			
			// Check if there is min amount of images
			redisReply *minImages = redisCommand(Context, "SCARD %s", targetList->element[i]->str);
			
			if (minImages->integer >= MIN_EACH_TYPE) {
				
				redisReply *currentTarget = redisCommand(Context, "SMEMBERS %s", targetList->element[i]->str);
				
				int randomTargetArray[MIN_EACH_TYPE] = {0, 0, 0};
				generateRandomTargetGroups(1, MIN_EACH_TYPE, randomTargetArray);
				
				printf("\nFor %s we are using:\n", targetList->element[i]->str);
				
				int j = 0;
				
				for (j = 0; j < MIN_EACH_TYPE; j++) {
					
					/*
					 * Get Each Target
					 */
					char targetFileName[64];
					
					strcpy(targetFileName, "");
					strcat(targetFileName, TargetDIR);
					strcat(targetFileName, "/");
					strcat(targetFileName, currentTarget->element[j]->str);
					strcat(targetFileName, ".png");
					
					printf("\t%s\n", currentTarget->element[j]->str);
					
					// Get a background image
					gdImagePtr targetImage = loadImage(targetFileName, ".png");
					
					int top = generateRandomNumber(100, (background->sx - 100));
					int bottom = top + targetImage->sy;
					int left = generateRandomNumber(100, (background->sy - 100));
					int right = left + targetImage->sx;
					
					// Write out info to file
					FILE *coords = fopen("puzzle.txt", "a");
					fprintf(coords, "%d, %d, %d, %d\n", top, bottom, left, right);
					fclose(coords);
					
					gdImageCopy(background, targetImage,
								top,
								left,
								0, 0, 100, targetImage->sy);
					
					gdImageDestroy(targetImage);
				}
				
				// Free
				freeReplyObject(currentTarget);
				
				
			} else {
				printf("Add %lld more target groups to %s\n", (MIN_EACH_TYPE - minImages->integer),
					   targetList->element[0]->str);
				break;
			}
			
			// Get random image category for user to chose
			redisReply *targetListCount = redisCommand(Context, "SCARD %s", GRP_TARGET_NAME);
			int randomTargetGroup = generateRandomNumber(1, (int)targetListCount->integer);
			freeReplyObject(targetListCount);
			
			redisReply *currentTarget = redisCommand(Context, "SMEMBERS %s", targetList->element[randomTargetGroup-1]->str);
			char *fileName = currentTarget->element[0]->str;
			
			char fileNameFinal[64];
			strcpy(fileNameFinal, "");
			strcat(fileNameFinal, TargetDIR);
			strcat(fileNameFinal, "/");
			strcat(fileNameFinal, fileName);
			strcat(fileNameFinal, ".png");
			
			// Get image of random target
			gdImagePtr lookingFor = loadImage(fileNameFinal, ".png");
			
			// Make HTML page
			generateHTML(background, lookingFor);
			
			freeReplyObject(currentTarget);
			freeReplyObject(minImages);
			
		}
		
		gdImageDestroy(background);
		freeReplyObject(targetList);
		
	} else {
		printf("Add %lu more target groups\n", (MIN_IMAGE_TYPES - keyCount));
	}
	
}
Exemplo n.º 9
0
void menu(){
int wyb=0;
int end=1;
char pom[20];
while(end){
	char pomInsert[50];
	char pomInsert2[50];
	char pomInsert3[50];
	char sqlscript[300]="INSERT INTO ksiazka(id_autor,tytul,ksiazka_gatunek,cena,rabat)VALUES (";
	char sqlscriptAut[300]="INSERT INTO autor(imie,nazwisko,rok_ur,pochodzenie)VALUES ('"; 
	char sqlscriptUp[300]="UPDATE autor SET ";
		char sqlscriptUpKs[300]="UPDATE ksiazka SET ";
	char sqldeletescript[300]="";
	printf("Co chcesz zrobic ?\n");
	printf("[1] dodaj rekord\n");//jest
	printf("[2] usun rekord\n");//jest
	printf("[3] wyswietl wszystko\n");//jest
	printf("[4] modyfikuj rekord\n");//brak pomyslu
	printf("[5] szukaj\n");//jest
	printf("[6] generuj html\n");//jest
	printf("[7] zakoncz\n");
	printf("Wybierasz : ");
	scanf("%d",&wyb);
	switch(wyb){
		case 1:
			printf("Wybierz tabele\n");
			printf("[1] autor\n");
			printf("[2] ksiazka\n");
			printf("Wybierasz : ");
			scanf("%d",&wyb);
				switch(wyb){
					case 1:
						printf("Podaj imie autora : ");
							scanf("%s",pomInsert);
							strcat(sqlscriptAut,pomInsert);
							strcat(sqlscriptAut,"','");
						printf("Podaj nazwisko autora : ");
							scanf("%s",pomInsert);
							strcat(sqlscriptAut,pomInsert);
							strcat(sqlscriptAut,"','");
						printf("Podaj rok urodzenia : ");
							scanf("%s",pomInsert);
							strcat(sqlscriptAut,pomInsert);
							strcat(sqlscriptAut,"','");
						printf("Podaj pochodzenie : ");
							scanf("%s",pomInsert);
							strcat(sqlscriptAut,pomInsert);
							strcat(sqlscriptAut,"');");
						doSQL(conn,sqlscriptAut);
						
						continue;
					case 2:
						printf("Podaj id autora : ");
							scanf("%s",pomInsert);
							strcat(sqlscript,pomInsert);
							strcat(sqlscript,",'");
						printf("Podaj tytul ksiazki uzwyajac _ zamiast spacji : ");
							scanf("%s",pomInsert);
							strcat(sqlscript,pomInsert);
							strcat(sqlscript,"','");
						printf("Podaj gatunek : ");
							scanf("%s",pomInsert);
							strcat(sqlscript,pomInsert);
							strcat(sqlscript,"','");
						printf("Podaj cene : ");
							scanf("%s",pomInsert);
							strcat(sqlscript,pomInsert);
							strcat(sqlscript,"','");
						printf("Podaj rabat : ");
							scanf("%s",pomInsert);
							strcat(sqlscript,pomInsert);
							strcat(sqlscript,"');");
						doSQL(conn,sqlscript);
						continue;
				}
		case 2:		
			printf("Wybierz tabele\n");
				printf("[1] autor\n");
				printf("[2] ksiazka\n");
				printf("Wybierasz : ");
				scanf("%d",&wyb);
				switch(wyb){
					case 1:
						printf("podaj id autora : ");
						scanf("%s",pomInsert);
						deleteAutor(pomInsert);
						continue;
					case 2:
						printf("podaj id ksiazki : ");
						scanf("%s",pomInsert);
						deleteBook(pomInsert);
						continue;
				}
		case 3:
			printf("\n[KSIAZKA]\n\n");
        		doSQL(conn,"SELECT * FROM ksiazka;");
        	printf("\n[AUTOR]\n\n");
				doSQL(conn,"SELECT * FROM autor;");
			continue;		
		case 4:
			printf("Wybierz tabele\n");
			printf("[1] autor\n");
			printf("[2] ksiazka\n");
			printf("Wybierasz : ");
			scanf("%d",&wyb);
				switch(wyb){
					case 1:
						printf("Podaj nazwisko autora ktorego chcesz edytowac : ");
						scanf("%s",pomInsert2);
						printf("\nCzy zmieniamy imie? Jesli nie wpisz 0 jesli tak podaj nowe imie : ");
						scanf("%s",pomInsert);
							if(strcmp(pomInsert,"0")!=0){
								strcat(sqlscriptUp,"imie='");
								strcat(sqlscriptUp,pomInsert);
								strcat(sqlscriptUp,"'");
							}
						strcpy(pomInsert3, pomInsert);
						
						printf("\nCzy zmieniamy nazwisko? Jesli nie wpisz 0 jesli tak podaj nowe nazwisko : ");
						scanf("%s",pomInsert);
							
							if(strcmp(pomInsert,"0")!=0){
								if(strcmp(pomInsert3,"0")!=0)
									strcat(sqlscriptUp,",");
								strcat(sqlscriptUp," nazwisko='");
								strcat(sqlscriptUp,pomInsert);
								strcat(sqlscriptUp,"'");
								strcpy(pomInsert3, pomInsert);
							}
							
							
						printf("\nCzy zmieniamy rok_urodzenia? Jesli nie wpisz 0 jesli tak podaj nowy rok_rodzenia : ");
						scanf("%s",pomInsert);
							
							if(strcmp(pomInsert,"0")!=0){
								if(strcmp(pomInsert3,"0")!=0)
									strcat(sqlscriptUp,",");
								strcat(sqlscriptUp," rok_ur='");
								strcat(sqlscriptUp,pomInsert);
								strcat(sqlscriptUp,"'");
								strcpy(pomInsert3, pomInsert);
							}
							
							
						printf("\nCzy zmieniamy pochodzenie? Jesli nie wpisz 0 jesli tak podaj nowe pochodzenie : ");
						scanf("%s",pomInsert);
							
							if(strcmp(pomInsert,"0")!=0){
								if(strcmp(pomInsert3,"0")!=0)
									strcat(sqlscriptUp,",");
								strcat(sqlscriptUp," pochodzenie='");
								strcat(sqlscriptUp,pomInsert);
								strcat(sqlscriptUp,"'");
							}
							strcat(sqlscriptUp," WHERE nazwisko='");
							strcat(sqlscriptUp,pomInsert2);
							strcat(sqlscriptUp,"';");
							doSQL(conn,sqlscriptUp);
						continue;
					case 2:
						printf("Podaj tytul ksiazki ktora chcesz edytowac : ");
						scanf("%s",pomInsert2);
						printf("\nCzy zmieniamy tytul? Jesli nie wpisz 0 jesli tak podaj nowy tytul : ");
						scanf("%s",pomInsert);
							if(strcmp(pomInsert,"0")!=0){
								strcat(sqlscriptUpKs,"tytul='");
								strcat(sqlscriptUpKs,pomInsert);
								strcat(sqlscriptUpKs,"'");
							}
						strcpy(pomInsert3, pomInsert);
							
						printf("\nCzy zmieniamy gatunek? Jesli nie wpisz 0 jesli tak podaj nowy gatunek : ");
						scanf("%s",pomInsert);
							
							if(strcmp(pomInsert,"0")!=0){
								if(strcmp(pomInsert3,"0")!=0)
									strcat(sqlscriptUpKs,",");
								strcat(sqlscriptUpKs," ksiazka_gatunek='");
								strcat(sqlscriptUpKs,pomInsert);
								strcat(sqlscriptUpKs,"'");
								strcpy(pomInsert3, pomInsert);
							}
						
							
						printf("\nCzy zmieniamy cene? Jesli nie wpisz 0 jesli tak podaj nowa cene : ");
						scanf("%s",pomInsert);
							
							if(strcmp(pomInsert,"0")!=0){
								if(strcmp(pomInsert3,"0")!=0)
									strcat(sqlscriptUpKs,",");
								strcat(sqlscriptUpKs," cena='");
								strcat(sqlscriptUpKs,pomInsert);
								strcat(sqlscriptUpKs,"'");
								strcpy(pomInsert3, pomInsert);
							}
							
						
						printf("\nCzy zmieniamy rabat? Jesli nie wpisz 0 jesli tak podaj nowy rabat : ");
						scanf("%s",pomInsert);
							
							if(strcmp(pomInsert,"0")!=0){
								if(strcmp(pomInsert3,"0")!=0)
									strcat(sqlscriptUpKs,",");
								strcat(sqlscriptUpKs," rabat='");
								strcat(sqlscriptUpKs,pomInsert);
								strcat(sqlscriptUpKs,"'");
							}
							strcat(sqlscriptUpKs," WHERE tytul='");
							strcat(sqlscriptUpKs,pomInsert2);
							strcat(sqlscriptUpKs,"';");
							doSQL(conn,sqlscriptUpKs);
						continue;
				}
			continue;
		case 5:
				printf("Wybierz tabele\n");
				printf("[1] autor\n");
				printf("[2] ksiazka\n");
				printf("Wybierasz : ");
				scanf("%d",&wyb);
				switch(wyb){
					case 1:
						printf("podaj nazwisko autora : ");
						scanf("%s",pomInsert);
						searchAutor(pomInsert);
						continue;
					case 2:
						printf("podaj tytul : ");
						scanf("%s",pomInsert);
						searchBook(pomInsert);
						continue;
				}
		case 6:
			generateHTML();
			continue;
		case 7:
			end=0;
			printf("\n\t\tKoniec tego dobrego :)\n\n");						
			break;
		default:
			printf("\nBledny wybor sprobuj jeszcze raz.\n");
		}


	}

}