bool BZFSHTTP::handleRequest(const HTTPRequest &request, HTTPReply &reply) { if (serviceMimeResources && resourceRootPath.size() && mimeTypes.size()) { // parse out the resource and see if we know what it is std::string ext; tolower(getFileExtension(request.resource),ext); if (ext.size()) { if ( mimeTypes.find(ext) != mimeTypes.end() ) { // it's one we do, try and find it std::string filepath = concatPaths(resourceRootPath.c_str(),request.resource.c_str()); FILE *fp = fopen(filepath.c_str(),"rb"); if (fp) { char buffer[1024]; bool done = false; while (!done) { size_t read = fread(buffer,1,1024,fp); if (read) reply.addBody(buffer,read); if (read != 1024) done = true; } fclose(fp); reply.docType = HTTPReply::eOther; reply.otherMimeType = mimeTypes[ext]; reply.returnCode = HTTPReply::e200OK; return true; } } } } return generatePage(request,reply); }
void selectPage(char *request) { char page[255]; fprintf(stderr, "Request: %s\n", request); fflush(stderr); if(strcmp(request, "main") == 0) sprintf(page, "/var/www/main.html"); else if(actualSession->login[0] != '\0') sprintf(page, "/var/www/main.html"); else sprintf(page, "/var/www/index.html"); fprintf(stderr, "login: %s\nPage choisie: %s\n", actualSession->login, page); generatePage(page); }
CategoryListModel::CategoryListModel(QObject *parent) : QAbstractListModel(parent) { paginationModel = new PaginationListModel; currentCategoryDetail = new CategoryDetail; currentPage = totalPage = 1; generatePage(currentPage, totalPage); roles = QAbstractListModel::roleNames(); roles.insert(IdRole, QByteArray("id")); roles.insert(NameRole, QByteArray("itemName")); roles.insert(ApprovedRole, QByteArray("approved")); roles.insert(LastUpdateRole, QByteArray("lastUpdate")); #if QT_VERSION < 0x050000 setRoleNames(roles); #endif }