Ejemplo n.º 1
0
void Dispatcher::dispatch() {
  assert(GetCurrentThreadId() == threadId);
  NativeContext* context;
  for (;;) {
    if (firstResumingContext != nullptr) {
      context = firstResumingContext;
      firstResumingContext = context->next;

      assert(context->inExecutionQueue);
      context->inExecutionQueue = false;
      
      break;
    }

    LARGE_INTEGER frequency;
    LARGE_INTEGER ticks;
    QueryPerformanceCounter(&ticks);
    QueryPerformanceFrequency(&frequency);
    uint64_t currentTime = ticks.QuadPart / (frequency.QuadPart / 1000);
    auto timerContextPair = timers.begin();
    auto end = timers.end();
    while (timerContextPair != end && timerContextPair->first <= currentTime) {
      pushContext(timerContextPair->second);
      timerContextPair = timers.erase(timerContextPair);
    }

    if (firstResumingContext != nullptr) {
      context = firstResumingContext;
      firstResumingContext = context->next;

      assert(context->inExecutionQueue);
      context->inExecutionQueue = false;

      break;
    }

    DWORD timeout = timers.empty() ? INFINITE : static_cast<DWORD>(std::min(timers.begin()->first - currentTime, static_cast<uint64_t>(INFINITE - 1)));
    OVERLAPPED_ENTRY entry;
    ULONG actual = 0;
    if (GetQueuedCompletionStatusEx(completionPort, &entry, 1, &actual, timeout, TRUE) == TRUE) {
      if (entry.lpOverlapped == reinterpret_cast<LPOVERLAPPED>(remoteSpawnOverlapped)) {
        EnterCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(criticalSection));
        assert(remoteNotificationSent);
        assert(!remoteSpawningProcedures.empty());
        do {
          spawn(std::move(remoteSpawningProcedures.front()));
          remoteSpawningProcedures.pop();
        } while (!remoteSpawningProcedures.empty());

        remoteNotificationSent = false;
        LeaveCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(criticalSection));
        continue;
      }

      context = reinterpret_cast<DispatcherContext*>(entry.lpOverlapped)->context;
      break;
    }

    DWORD lastError = GetLastError();
    if (lastError == WAIT_TIMEOUT) {
      continue;
    }

    if (lastError != WAIT_IO_COMPLETION) {
      throw std::runtime_error("Dispatcher::dispatch, GetQueuedCompletionStatusEx failed, " + errorMessage(lastError));
    }
  }

  if (context != currentContext) {
    currentContext = context;
    SwitchToFiber(context->fiber);
  }
}
Ejemplo n.º 2
0
bool ScriptDebuggerPrivate::executeCommand(const QString &command, const QStringList &args)
{
    if (command == QLatin1String("c")
        || command == QLatin1String("continue")) {
        setMode(Run);
        return true;
    } else if (command == QLatin1String("s")
               || command == QLatin1String("step")) {
        setMode(StepInto);
        return true;
    } else if (command == QLatin1String("n")
               || command == QLatin1String("next")) {
        setMode(StepOver);
        m_stepDepth = 0;
        return true;
    } else if (command == QLatin1String("f")
               || command == QLatin1String("frame")) {
        bool ok = false;
        int index = args.value(0).toInt(&ok);
        if (ok) {
            if (index < 0 || index >= frameCount()) {
                errorMessage("No such frame.");
            } else {
                setCurrentFrameIndex(index);
                QScriptContext *ctx = currentFrameContext();
                message(QString::fromLatin1("#%0  %1").arg(index).arg(ctx->toString()));
            }
        }
    } else if (command == QLatin1String("bt")
               || command == QLatin1String("backtrace")) {
        QScriptContext *ctx = engine()->currentContext();
        int index = -1;
        while (ctx) {
            ++index;
            QString line = ctx->toString();
            message(QString::fromLatin1("#%0  %1").arg(index).arg(line));
            ctx = ctx->parentContext();
        }
    } else if (command == QLatin1String("up")) {
        int index = currentFrameIndex() + 1;
        if (index == frameCount()) {
            errorMessage(QString::fromLatin1("Initial frame selected; you cannot go up."));
        } else {
            setCurrentFrameIndex(index);
            QScriptContext *ctx = currentFrameContext();
            message(QString::fromLatin1("#%0  %1").arg(index).arg(ctx->toString()));
        }
    } else if (command == QLatin1String("down")) {
        int index = currentFrameIndex() - 1;
        if (index < 0) {
            errorMessage(QString::fromLatin1("Bottom (innermost) frame selected; you cannot go down."));
        } else {
            setCurrentFrameIndex(index);
            QScriptContext *ctx = currentFrameContext();
            message(QString::fromLatin1("#%0  %1").arg(index).arg(ctx->toString()));
        }
    } else if (command == QLatin1String("b")
               || command == QLatin1String("break")) {
        QString str = args.value(0);
        int colonIndex = str.indexOf(QLatin1Char(':'));
        if (colonIndex != -1) {
            // filename:line form
            QString fileName = str.left(colonIndex);
            int lineNumber = str.mid(colonIndex+1).toInt();
            int id = m_bpManager->setBreakpoint(fileName, lineNumber);
            message(QString::fromLatin1("Breakpoint %0 at %1, line %2.").arg(id+1).arg(fileName).arg(lineNumber));
        } else {
            // function
            QScriptValue fun = engine()->globalObject().property(str);
            if (fun.isFunction()) {
                int id = m_bpManager->setBreakpoint(fun);
                message(QString::fromLatin1("Breakpoint %0 at %1().").arg(id+1).arg(str));
            }
        }
    } else if (command == QLatin1String("d")
               || command == QLatin1String("delete")) {
        int id = args.value(0).toInt() - 1;
        m_bpManager->removeBreakpoint(id);
    } else if (command == QLatin1String("disable")) {
        int id = args.value(0).toInt() - 1;
        m_bpManager->setBreakpointEnabled(id, false);
    } else if (command == QLatin1String("enable")) {
        int id = args.value(0).toInt() - 1;
        m_bpManager->setBreakpointEnabled(id, true);
    } else if (command == QLatin1String("list")) {
        QScriptContext *ctx = currentFrameContext();
        ScriptInfo *progInfo = scriptInfo(ctx);
        if (!progInfo) {
            errorMessage("No source text available for this frame.");
        } else {
            QScriptContextInfo ctxInfo(ctx);
            bool ok;
            int line = args.value(0).toInt(&ok);
            if (ok) {
                line = qMax(1, line - 5);
            } else {
                line = listLineNumber();
                if (line == -1)
                    line = qMax(progInfo->lineNumber(), ctxInfo.lineNumber() - 5);
            }
            for (int i = line; i < line + 10; ++i) {
                message(QString::fromLatin1("%0\t%1").arg(i).arg(progInfo->lineText(i)));
            }
            setListLineNumber(line + 10);
        }
    } else if (command == QLatin1String("info")) {
        if (args.size() < 1) {
        } else {
            QString what = args.value(0);
            if (what == QLatin1String("locals")) {
                QScriptValueIterator it(currentFrameContext()->activationObject());
                while (it.hasNext()) {
                    it.next();
                    QString line;
                    line.append(it.name());
                    line.append(QLatin1String(" = "));
                    line.append(safeValueToString(it.value()));
                    message(line);
                }
            }
        }
    } else if (command == QLatin1String("help")) {
        message("continue - continue execution\n"
                "step     - step into statement\n"
                "next     - step over statement\n"
                "list     - show where you are\n"
                "\n"
                "break    - set breakpoint\n"
                "delete   - remove breakpoint\n"
                "disable  - disable breakpoint\n"
                "enable   - enable breakpoint\n"
                "\n"
                "backtrace - show backtrace\n"
                "up       - one frame up\n"
                "down     - one frame down\n"
                "frame    - set frame\n"
                "\n"
                "info locals - show local variables");
    } else {
        errorMessage(QString::fromLatin1("Undefined command \"%0\". Try \"help\".")
                     .arg(command));
    }

    return false;
}
Ejemplo n.º 3
0
double CoolPropSolver::isentropicEnthalpy(double &p, ExternalThermodynamicState *const properties){
    // Base function returns an error if called - should be redeclared by the solver object
	errorMessage((char*)"Internal error: isentropicEnthalpy() not implemented in the Solver object");
	throw NotImplementedError((char*)"Internal error: isentropicEnthalpy() not implemented in the Solver object");
	return 0;
}
Ejemplo n.º 4
0
TcpConnection TcpListener::accept() {
  assert(dispatcher != nullptr);
  assert(context == nullptr);
  if (dispatcher->interrupted()) {
    throw InterruptedException();
  }

  std::string message;
  SOCKET connection = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (connection == INVALID_SOCKET) {
    message = "socket failed, " + errorMessage(WSAGetLastError());
  } else {
    uint8_t addresses[sizeof sockaddr_in * 2 + 32];
    DWORD received;
    TcpListenerContext context2;
    context2.hEvent = NULL;
    if (acceptEx(listener, connection, addresses, 0, sizeof(sockaddr_in) + 16, sizeof(sockaddr_in) + 16, &received, &context2) == TRUE) {
      message = "AcceptEx returned immediately, which is not supported.";
    } else {
      int lastError = WSAGetLastError();
      if (lastError != WSA_IO_PENDING) {
        message = "AcceptEx failed, " + errorMessage(lastError);
      } else {
        context2.context = dispatcher->getCurrentContext();
        context2.interrupted = false;
        context = &context2;
        dispatcher->getCurrentContext()->interruptProcedure = [&]() {
          assert(dispatcher != nullptr);
          assert(context != nullptr);
          TcpListenerContext* context2 = static_cast<TcpListenerContext*>(context);
          if (!context2->interrupted) {
            if (CancelIoEx(reinterpret_cast<HANDLE>(listener), context2) != TRUE) {
              DWORD lastError = GetLastError();
              if (lastError != ERROR_NOT_FOUND) {
                throw std::runtime_error("TcpListener::stop, CancelIoEx failed, " + lastErrorMessage());
              }

              context2->context->interrupted = true;
            }

            context2->interrupted = true;
          }
        };

        dispatcher->dispatch();
        dispatcher->getCurrentContext()->interruptProcedure = nullptr;
        assert(context2.context == dispatcher->getCurrentContext());
        assert(dispatcher != nullptr);
        assert(context == &context2);
        context = nullptr;
        DWORD transferred;
        DWORD flags;
        if (WSAGetOverlappedResult(listener, &context2, &transferred, FALSE, &flags) != TRUE) {
          lastError = WSAGetLastError();
          if (lastError != ERROR_OPERATION_ABORTED) {
            message = "AcceptEx failed, " + errorMessage(lastError);
          } else {
            assert(context2.interrupted);
            if (closesocket(connection) != 0) {
              throw std::runtime_error("TcpListener::accept, closesocket failed, " + errorMessage(WSAGetLastError()));
            } else {
              throw InterruptedException();
            }
          }
        } else {
          if (context2.interrupted) {
            if (closesocket(connection) != 0) {
              throw std::runtime_error("TcpConnector::connect, closesocket failed, " + errorMessage(WSAGetLastError()));
            }
            else {
              throw InterruptedException();
            }
          }

          assert(transferred == 0);
          assert(flags == 0);
          if (setsockopt(connection, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, reinterpret_cast<char*>(&listener), sizeof listener) != 0) {
            message = "setsockopt failed, " + errorMessage(WSAGetLastError());
          } else {
            if (CreateIoCompletionPort(reinterpret_cast<HANDLE>(connection), dispatcher->getCompletionPort(), 0, 0) != dispatcher->getCompletionPort()) {
              message = "CreateIoCompletionPort failed, " + lastErrorMessage();
            } else {
              return TcpConnection(*dispatcher, connection);
            }
          }
        }
      }
    }

    int result = closesocket(connection);
    assert(result == 0);
  }

  throw std::runtime_error("TcpListener::accept, " + message);
}
Ejemplo n.º 5
0
void Monitor::updateAll(){
    int id;
    int err;
    int row;
    int cpuRow;
    uint64_t totalTime;
    uint64_t taskTime;
    sys_taskattr_t task;
    CNotify notify;
    id = 0;

    if( link()->isConnected() == false ){
        return;
    }

    if( fd < 0 ){
        return;
    }

    do {
        if ( link()->isConnected() == false ){
            stopTimer();
            for(row = 0; row < ui->table->rowCount(); row++){
                ui->table->removeRow(row);
            }
            return;
        }

        task.is_enabled = 0;
        task.tid = id;
        err = link()->ioctl(fd, I_SYS_GETTASK, &task);
        if ( err < -2 ){
            stopTimer();
            for(row = 0; row < ui->table->rowCount(); row++){
                ui->table->removeRow(row);
            }
            notify.execError( errorMessage() );
            return;
        }

        //update the entries in the table
        updateRow(id, &task);
        id++;
    } while( err != -1 );


    cpuRow = ui->table->rowCount();
    totalTime = 0;
    for(row = 0; row < cpuRow; row++){
        totalTime += ui->table->item(row, DELTA_TASK_TIME_COL)->text().toLongLong();
    }


    for(row = 0; row < cpuRow; row++){
        taskTime = ui->table->item(row, DELTA_TASK_TIME_COL)->text().toLongLong();
        updateItem(row, CPU_COL, QString::number( taskTime * 100.0 / totalTime, 'f', 2 ));
    }

    ui->table->sortItems(sortColumn, sortOrder);


}
Ejemplo n.º 6
0
void Groupwise::getAddressbook(const KURL &url)
{
    QString u = soapUrl(url);

    QString user = url.user();
    QString pass = url.pass();

    debugMessage("URL: " + u);
    debugMessage("User: "******"Password: "******"?")
    {
        errorMessage(i18n("No addressbook IDs given."));
    }
    else
    {
        QStringList ids;

        query = query.mid(1);
        QStringList queryItems = QStringList::split("&", query);
        QStringList::ConstIterator it;
        for(it = queryItems.begin(); it != queryItems.end(); ++it)
        {
            QStringList item = QStringList::split("=", (*it));
            if(item.count() == 2 && item[ 0 ] == "addressbookid")
            {
                ids.append(item[ 1 ]);
            }
        }

        debugMessage("IDs: " + ids.join(","));

        GroupwiseServer server(u, user, pass, 0);

        connect(&server, SIGNAL(readAddressBookTotalSize(int)),
                SLOT(slotReadAddressBookTotalSize(int)));
        connect(&server, SIGNAL(readAddressBookProcessedSize(int)),
                SLOT(slotReadAddressBookProcessedSize(int)));
        connect(&server, SIGNAL(errorMessage(const QString &, bool)),
                SLOT(slotServerErrorMessage(const QString &, bool)));
        connect(&server, SIGNAL(gotAddressees(const KABC::Addressee::List)),
                SLOT(slotReadReceiveAddressees(const KABC::Addressee::List)));

        kdDebug() << "Login" << endl;
        if(!server.login())
        {
            errorMessage(i18n("Unable to login: "******"Read Addressbook" << endl;
            if(!server.readAddressBooksSynchronous(ids))
            {
                errorMessage(i18n("Unable to read addressbook data: ") + server.errorText());
            }
            kdDebug() << "Logout" << endl;
            server.logout();
            finished();
        }
    }
}
Ejemplo n.º 7
0
void Groupwise::slotServerErrorMessage(const QString &serverErrorMessage, bool fatal)
{
    kdDebug() << "Groupwise::slotJobErrorMessage()" << serverErrorMessage << (fatal ? ", FATAL!" : ", proceeding") << endl;
    errorMessage(i18n("An error occurred while communicating with the GroupWise server:\n%1").arg(serverErrorMessage));
}
Ejemplo n.º 8
0
void getNiftiImageOrientation(const char *filename, char *orientation)
{
   FILE *fp;
   nifti_1_header hdr;
   int swapflg=0;

   orientation[0]='\0';

   // ensure that the specified image has either a .hdr or a .nii extension
   if( !checkNiftiFileExtension(filename) )
   {
      errorMessage("The image filename must have a `.hdr' or `.nii' extension.");
   }

   fp = fopen(filename,"r");

   if(fp==NULL)
   {
      file_open_error(filename);
   }

   if( fread(&hdr, sizeof(nifti_1_header), 1, fp) != 1 )
   {
      errorMessage("I have trouble reading the specified image file.");
   }

   fclose(fp);

   // looks like ANALYZE 7.5, cannot determine orientation
   if( hdr.magic[0]!='n' ||  (hdr.magic[1]!='+' && hdr.magic[1]!='i') ||  hdr.magic[2]!='1')
   {
      printf("\nWarning: Could not determine %s image orientation ...\n",filename);
      return;
   }

   // if dim[0] is outside range 1..7, then the header information
   // needs to be byte swapped appropriately
   if(hdr.dim[0]<1 || hdr.dim[0]>7) 
   {
      swapflg=1;
   }

   // Here I am only byte swapping the header fields relevant for determining the image orientation
   if(swapflg)
   {
      swapByteOrder( (char *)&(hdr.qform_code), sizeof(short));
      swapByteOrder( (char *)&(hdr.sform_code), sizeof(short));
      swapByteOrder( (char *)&(hdr.quatern_b), sizeof(float));
      swapByteOrder( (char *)&(hdr.quatern_c), sizeof(float));
      swapByteOrder( (char *)&(hdr.quatern_d), sizeof(float));
      swapByteOrder( (char *)&(hdr.qoffset_x), sizeof(float));
      swapByteOrder( (char *)&(hdr.qoffset_y), sizeof(float));
      swapByteOrder( (char *)&(hdr.qoffset_z), sizeof(float));
      for(int i=0; i<4; i++)
      {
         swapByteOrder( (char *)&(hdr.srow_x[i]), sizeof(float));
         swapByteOrder( (char *)&(hdr.srow_y[i]), sizeof(float));
         swapByteOrder( (char *)&(hdr.srow_z[i]), sizeof(float));
      }
   }

   if(hdr.qform_code == 0 && hdr.sform_code == 0) 
   {
      printf("\nWarning: Could not determine %s image orientation ...\n",filename);
      printf("\nWarning: The header of this \"NIFTI\" file does not contain orientation information.\n");
      return;
   }

   if(hdr.qform_code > 0 )
   {
      mat44 R;

      R = nifti_quatern_to_mat44(hdr.quatern_b, hdr.quatern_c, hdr.quatern_d, hdr.qoffset_x, hdr.qoffset_y, 
      hdr.qoffset_z, hdr.pixdim[1], hdr.pixdim[2], hdr.pixdim[3], hdr.pixdim[0]);

      orientation[0] = directionCode(R.m[0][0],R.m[1][0],R.m[2][0]);
      orientation[1] = directionCode(R.m[0][1],R.m[1][1],R.m[2][1]);
      orientation[2] = directionCode(R.m[0][2],R.m[1][2],R.m[2][2]);
      orientation[3] = '\0';
   }
   else
   {
      orientation[0] = directionCode(hdr.srow_x[0],hdr.srow_y[0],hdr.srow_z[0]);
      orientation[1] = directionCode(hdr.srow_x[1],hdr.srow_y[1],hdr.srow_z[1]);
      orientation[2] = directionCode(hdr.srow_x[2],hdr.srow_y[2],hdr.srow_z[2]);
      orientation[3] = '\0';
   }

   return;
}
Ejemplo n.º 9
0
void LaunchSimulationBox::showErrorMsg()
{
    gvle::Error(errorMessage());
}
Ejemplo n.º 10
0
 MysqlStmtError::MysqlStmtError(MYSQL_STMT* stmt)
   : MysqlError(errorMessage(stmt))
   { }
Ejemplo n.º 11
0
 MysqlStmtError::MysqlStmtError(const char* function,
   MYSQL_STMT* stmt)
   : MysqlError(errorMessage(function, stmt))
   { }
Ejemplo n.º 12
0
 MysqlError::MysqlError(const char* function, MYSQL* mysql)
   : Error(errorMessage(function, mysql))
   { }
Ejemplo n.º 13
0
 MysqlError::MysqlError(MYSQL* mysql)
   : Error(errorMessage(mysql))
   { }
Ejemplo n.º 14
0
void Dispatcher::yield() {
  assert(GetCurrentThreadId() == threadId);
  for (;;) {
    LARGE_INTEGER frequency;
    LARGE_INTEGER ticks;
    QueryPerformanceCounter(&ticks);
    QueryPerformanceFrequency(&frequency);
    uint64_t currentTime = ticks.QuadPart / (frequency.QuadPart / 1000);
    auto timerContextPair = timers.begin();
    auto end = timers.end();
    while (timerContextPair != end && timerContextPair->first <= currentTime) {
      timerContextPair->second->interruptProcedure = nullptr;
      pushContext(timerContextPair->second);
      timerContextPair = timers.erase(timerContextPair);
    }

    OVERLAPPED_ENTRY entries[16];
    ULONG actual = 0;
    if (GetQueuedCompletionStatusEx(completionPort, entries, 16, &actual, 0, TRUE) == TRUE) {
      assert(actual > 0);
      for (ULONG i = 0; i < actual; ++i) {
        if (entries[i].lpOverlapped == reinterpret_cast<LPOVERLAPPED>(remoteSpawnOverlapped)) {
          EnterCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(criticalSection));
          assert(remoteNotificationSent);
          assert(!remoteSpawningProcedures.empty());
          do {
            spawn(std::move(remoteSpawningProcedures.front()));
            remoteSpawningProcedures.pop();
          } while (!remoteSpawningProcedures.empty());

          remoteNotificationSent = false;
          LeaveCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(criticalSection));
          continue;
        }

        NativeContext* context = reinterpret_cast<DispatcherContext*>(entries[i].lpOverlapped)->context;
        context->interruptProcedure = nullptr;
        pushContext(context);
      }
    } else {
      DWORD lastError = GetLastError();
      if (lastError == WAIT_TIMEOUT) {
        break;
      } else if (lastError != WAIT_IO_COMPLETION) {
        throw std::runtime_error("Dispatcher::yield, GetQueuedCompletionStatusEx failed, " + errorMessage(lastError));
      }
    }
  }

  if (firstResumingContext != nullptr) {
    pushContext(currentContext);
    dispatch();
  }
}
Ejemplo n.º 15
0
void SanyoProjector1::populateProtocol(
  QObject *guiObject)
{
  if (threadableProtocol)
  {
    // If the pointer is not null, the keyset must already be populated.
    return;
  }

  // Need to set the protocol to use 16-bit predata, for child keysets:
  threadableProtocol = new NECProtocol(guiObject, index, true, true);

  connect(
    threadableProtocol,
    SIGNAL(errorMessage(QString)),
    this,
    SIGNAL(errorMessage(QString)));

  setPreData(0xCF30, 16);

  addKey("Power", Power_Key, 0x00, 8); //"ONOFF0"
  addKey("D.Zoom +", Unmapped_Key, 0x01, 8);
  addKey("D.ZOOM -", Unmapped_Key, 0x02, 8);
  addKey("Input", Input_Key, 0x05, 8);
  addKey("VOLUME +", VolumeUp_Key, 0x09, 8);
  addKey("VOLUME -", VolumeDown_Key, 0x0A, 8);
  addKey("MUTE", Mute_Key, 0x0B, 8);
  addKey("Image (Adj.)", PictureMode_Key, 0x0C, 8);
  addKey("Image (z1)", Unmapped_Key, 0x0E, 8); // put into different keyset?
  addKey("SELECT", Select_Key, 0x0F, 8);
  addKey("INFORMATION", Info_Key, 0x16, 8);
  addKey("AUTO SET", Unmapped_Key, 0x17, 8);
  addKey("LAMP CONTROL", Unmapped_Key, 0x18, 8); // "(Lamp Mode)"
  addKey("MENU", Menu_Key, 0x1C, 8);
  addKey("RIGHT", Right_Key, 0x1D, 8);
  addKey("LEFT", Left_Key, 0x1E, 8);
  addKey("Standard (Image)", Unmapped_Key, 0x1F, 8);
  addKey("HDMI", HDMIInput_Key, 0x37, 8);
  addKey("COMPUTER 1", PCInput_Key, 0x38, 8);
  addKey("COMPUTER 2", LDInput_Key, 0x39, 8); // hack
  addKey("Input 3", PhonoInput_Key, 0x3A, 8); // hack
  addKey("AUTO", Unmapped_Key, 0x3C, 8); // "My-P (My Picture)"
  addKey("COMPOSITE", CompositeInput_Key, 0x3D, 8); // "VIDEO"
  addKey("S-VIDEO", SVideoInput_Key, 0x3E, 8); // "S-VIDEO"
  addKey("Lens Shift", Unmapped_Key, 0x40, 8);
  addKey("FREEZE", Pause_Key, 0x43, 8);
  addKey("Zoom -", Unmapped_Key, 0x46, 8);
  addKey("Zoom +", Unmapped_Key, 0x47, 8);
  addKey("Focus +", Unmapped_Key, 0x4A, 8);
  addKey("Focus -", Unmapped_Key, 0x4B, 8);
  addKey("IMAGE_1", One_Key, 0x50, 8);
  addKey("IMAGE_2", Two_Key, 0x51, 8);
  addKey("IMAGE_3", Three_Key, 0x56, 8);
  addKey("IMAGE_4", Four_Key, 0x57, 8);
  addKey("P-Im (Image, Preset)", Unmapped_Key, 0x58, 8);
  addKey("KEYSTONE", Unmapped_Key, 0x5B, 8);
  addKey("SCREEN", AspectRatio_Key, 0x82, 8); // "ASPECT"
  addKey("COMPONENT", ComponentInput_Key, 0x83, 8);
  addKey("AUTO_PC_ADJ", Unmapped_Key, 0x89, 8);
  addKey("P-TIMER", Unmapped_Key, 0x8A, 8);
  addKey("NOSHOW", Unmapped_Key, 0x8B, 8); // "AV MUTE"
  addKey("UP", Up_Key, 0x8C, 8);
  addKey("DOWN", Down_Key, 0x8D, 8);
  addKey("KEYSTONE_UP", Unmapped_Key, 0x8E, 8);
  addKey("KEYSTONE_DOWN", Unmapped_Key, 0x8F, 8);
  addKey("Power On", Green_Key, 0xA0, 8);
  addKey("Power Off", Red_Key, 0xA1, 8);
}
Ejemplo n.º 16
0
int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);
    QGuiApplication::setApplicationName("Presentao");
    QGuiApplication::setOrganizationName("Embedded_Multimedia");

    QSettings settings;
    QString style = QQuickStyle::name();
    if (!style.isEmpty())
        settings.setValue("style", style);
    else
        QQuickStyle::setStyle(settings.value("style").toString());

    web_socket_client websocketclient;

    audioWindow audioengine;

    QQmlApplicationEngine engine;
    engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    PdfRenderer myPdfRenderer;
    handcontrol myhandcontrol;
    engine.addImageProvider(QLatin1String("pdfrenderer"), &myPdfRenderer);

    QObject *root = engine.rootObjects()[0];

    //QObject::connect(root, SIGNAL(nextpage()),&myPdfRenderer, SLOT(nextPage()));
    //QObject::connect(root, SIGNAL(prevpage()),&myPdfRenderer, SLOT(prevPage()));
    QObject::connect(root, SIGNAL(openfile(QUrl)),&myPdfRenderer, SLOT(OpenPDF(QUrl)));
    QObject::connect(&myPdfRenderer, SIGNAL(sendTotalPageCount(QVariant)),root, SLOT(setTotalPageCount(QVariant)));


    /*
     * signals from web_socket_client
     * void OpenPDF(QString)
     * void signal_setPage(int)
     * void connection_success()
    */

    QObject::connect(&websocketclient, SIGNAL(OpenPDF(QUrl)),
                     &myPdfRenderer, SLOT(OpenPDF(QUrl)));
    QObject::connect(&websocketclient, SIGNAL(signal_setPage(QVariant)),
                     root, SLOT(setCurrentPageNr(QVariant)));
    QObject::connect(&websocketclient, SIGNAL(connection_success()),
                     root, SLOT(connection_success()));

    /*
     * slots of web_socket_client
     * void connect(QString)
     * void onConnected()
     * void onBinaryMessage(QByteArray)
     * void onTextMessage(QString)
     * void sendFile(QString filename)
     * void registerMaster(QString)
     * void download_pdf(QString filename)
     * void getPage()
     * void setPage(QString)
     */

    QObject::connect(root, SIGNAL(connect(QString)),
                     &websocketclient, SLOT(connect(QString)));
    QObject::connect(root, SIGNAL(registerMaster(QString)),
                     &websocketclient, SLOT(registerMaster(QString)));
    QObject::connect(root, SIGNAL(sendFile(QUrl)),
                     &websocketclient, SLOT(sendFile(QUrl)));
    QObject::connect(root, SIGNAL(download_pdf(QString)),
                     &websocketclient, SLOT(download_pdf(QString)));
    QObject::connect(root, SIGNAL(setPage(QString)),
                     &websocketclient, SLOT(setPage(QString)));
    QObject::connect(root, SIGNAL(getPage()),
                     &websocketclient, SLOT(getPage()));


    //AUDIO
     QObject::connect(root, SIGNAL(startstopKlopfen()),&audioengine, SLOT(startStopRecording()));
     QObject::connect(&audioengine, SIGNAL(knock()),root, SLOT(klopf_weiter()));
     QObject::connect(&audioengine, SIGNAL(double_knock()),root,SLOT(klopf_zurück()));


    // Gestensteuerng
    QObject *cameraComponent = root->findChild<QObject*>("camera");
    QCamera *camera = qvariant_cast<QCamera*>(cameraComponent->property("mediaObject"));
    myhandcontrol.setCamera(camera);
    QObject::connect(root, SIGNAL(handcontrol_enable(int)),&myhandcontrol, SLOT(enable(int)));
    QObject::connect(&myhandcontrol, SIGNAL(debugMessage(QVariant)),root, SLOT(handcontrol_debugOut(QVariant)));
    QObject::connect(&myhandcontrol, SIGNAL(errorMessage(QVariant)),root, SLOT(handcontrol_debugOut(QVariant)));
    QObject::connect(&myhandcontrol, SIGNAL(change_page(QVariant)),root, SLOT(handcontrol_change_page(QVariant)));
    qDebug()<<"From main thread: "<<QThread::currentThreadId();
    return app.exec();
}
Ejemplo n.º 17
0
void Groupwise::getFreeBusy(const KURL &url)
{
    QString file = url.filename();
    if(file.right(4) != ".ifb")
    {
        QString error = i18n("Illegal filename. File has to have '.ifb' suffix.");
        errorMessage(error);
    }
    else
    {
        QString email = file.left(file.length() - 4);
        debugMessage("Email: " + email);

        // Sanitise local Nuernberg email addresses
        kdDebug() << "Email before sanitizing: " << email << endl;
        email = email.replace(QRegExp("\\.EMEA5-1\\.EMEA5"), "");
        email = email.replace(QRegExp("\\.Suse.INTERNET"), "");
        kdDebug() << "Email after sanitizing: " << email << endl;

        QString u = soapUrl(url);

        QString user = url.user();
        QString pass = url.pass();

        debugMessage("URL: " + u);
        debugMessage("User: "******"Password: "******"Need username and password to read Free/Busy information."));
        }
        else
        {
            GroupwiseServer server(u, user, pass, 0);

            // FIXME: Read range from configuration or URL parameters.
            QDate start = QDate::currentDate().addDays(-3);
            QDate end = QDate::currentDate().addDays(60);

            fb->setDtStart(start);
            fb->setDtEnd(end);

            kdDebug() << "Login" << endl;

            if(!server.login())
            {
                errorMessage(i18n("Unable to login: "******"Read free/busy" << endl;
                if(!server.readFreeBusy(email, start, end, fb))
                {
                    errorMessage(i18n("Unable to read free/busy data: ") + server.errorText());
                }
                kdDebug() << "Read free/busy" << endl;
                server.logout();
            }
        }

#if 0
        QDateTime s = QDateTime(QDate(2004, 9, 27), QTime(10, 0));
        QDateTime e = QDateTime(QDate(2004, 9, 27), QTime(11, 0));

        fb->addPeriod(s, e);
#endif

        // FIXME: This does not take into account the time zone!
        KCal::ICalFormat format;

        QString ical = format.createScheduleMessage(fb, KCal::Scheduler::Publish);

        data(ical.utf8());

        finished();
    }
}
Ejemplo n.º 18
0
size_t TcpConnection::read(uint8_t* data, size_t size) {
  assert(dispatcher != nullptr);
  assert(readContext == nullptr);
  if (dispatcher->interrupted()) {
    throw InterruptedException();
  }

  WSABUF buf{static_cast<ULONG>(size), reinterpret_cast<char*>(data)};
  DWORD flags = 0;
  TcpConnectionContext context;
  context.hEvent = NULL;
  if (WSARecv(connection, &buf, 1, NULL, &flags, &context, NULL) != 0) {
    int lastError = WSAGetLastError();
    if (lastError != WSA_IO_PENDING) {
      throw std::runtime_error("TcpConnection::read, WSARecv failed, " + errorMessage(lastError));
    }
  }

  assert(flags == 0);
  context.context = dispatcher->getCurrentContext();
  context.interrupted = false;
  readContext = &context;
  dispatcher->getCurrentContext()->interruptProcedure = [&]() {
    assert(dispatcher != nullptr);
    assert(readContext != nullptr);
    TcpConnectionContext* context = static_cast<TcpConnectionContext*>(readContext);
    if (!context->interrupted) {
      if (CancelIoEx(reinterpret_cast<HANDLE>(connection), context) != TRUE) {
        DWORD lastError = GetLastError();
        if (lastError != ERROR_NOT_FOUND) {
          throw std::runtime_error("TcpConnection::stop, CancelIoEx failed, " + lastErrorMessage());
        }

        context->context->interrupted = true;
      }

      context->interrupted = true;
    }
  };

  dispatcher->dispatch();
  dispatcher->getCurrentContext()->interruptProcedure = nullptr;
  assert(context.context == dispatcher->getCurrentContext());
  assert(dispatcher != nullptr);
  assert(readContext == &context);
  readContext = nullptr;
  DWORD transferred;
  if (WSAGetOverlappedResult(connection, &context, &transferred, FALSE, &flags) != TRUE) {
    int lastError = WSAGetLastError();
    if (lastError != ERROR_OPERATION_ABORTED) {
      throw std::runtime_error("TcpConnection::read, WSAGetOverlappedResult failed, " + errorMessage(lastError));
    }

    assert(context.interrupted);
    throw InterruptedException();
  }

  assert(transferred <= size);
  assert(flags == 0);
  return transferred;
}
Ejemplo n.º 19
0
void Groupwise::updateAddressbook(const KURL &url)
{
    kdDebug() << "Groupwise::updateAddressbook() " << url << endl;
    QString u = soapUrl(url);

    QString user = url.user();
    QString pass = url.pass();

    debugMessage("update AB URL: " + u);
    debugMessage("update AB User: "******"update AB Password: "******"?")
    {
        errorMessage(i18n("No addressbook IDs given."));
        return;
    }
    else
    {
        QStringList ids;

        query = query.mid(1);
        QStringList queryItems = QStringList::split("&", query);
        QStringList::ConstIterator it;
        for(it = queryItems.begin(); it != queryItems.end(); ++it)
        {
            QStringList item = QStringList::split("=", (*it));
            if(item.count() == 2 && item[ 0 ] == "addressbookid")
            {
                ids.append(item[ 1 ]);
            }
            if(item.count() == 2 && item[ 0 ] == "lastSeqNo")
                lastSequenceNumber = item[ 1 ].toULong();
            if(item.count() == 2 && item[ 0 ] == "PORebuildTime")
                lastPORebuildTime = item[ 1 ].toULong();
        }

        debugMessage("update IDs: " + ids.join(","));

        GroupwiseServer server(u, user, pass, 0);
        connect(&server, SIGNAL(errorMessage(const QString &, bool)),
                SLOT(slotServerErrorMessage(const QString &, bool)));
        connect(&server, SIGNAL(gotAddressees(const KABC::Addressee::List)),
                SLOT(slotReadReceiveAddressees(const KABC::Addressee::List)));

        kdDebug() << "  Login" << endl;
        if(!server.login())
        {
            errorMessage(i18n("Unable to login: "******"  Updating Addressbook" << endl;
            if(!server.updateAddressBooks(ids, lastSequenceNumber + 1, lastPORebuildTime))
            {
                error(KIO::ERR_NO_CONTENT, server.errorText());
                //errorMessage( i18n("Unable to update addressbook data: ") + server.errorText() );
            }
            kdDebug() << "  Logout" << endl;
            server.logout();
            finished();
        }
    }
}
Ejemplo n.º 20
0
void QmlOutputParser::processOutput(const QString &output)
{
    m_buffer.append(output);

    while (true) {
        const int nlIndex = m_buffer.indexOf(QLatin1Char('\n'));
        if (nlIndex < 0) // no further complete lines
            break;

        const QString msg = m_buffer.left(nlIndex);
        m_buffer = m_buffer.right(m_buffer.size() - nlIndex - 1);

        // used in Qt4
        static const QString qddserver4 = QLatin1String("QDeclarativeDebugServer: ");
        // used in Qt5
        static const QString qddserver5 = QLatin1String("QML Debugger: ");

        QString status;
        int index = msg.indexOf(qddserver4);
        if (index != -1) {
            status = msg;
            status.remove(0, index + qddserver4.length()); // chop of 'QDeclarativeDebugServer: '
        } else {
            index = msg.indexOf(qddserver5);
            if (index != -1) {
                status = msg;
                status.remove(0, index + qddserver5.length()); // chop of 'QML Debugger: '
            }
        }
        if (!status.isEmpty()) {
            static QString waitingForConnection = QLatin1String(Constants::STR_WAITING_FOR_CONNECTION);
            static QString unableToListen = QLatin1String(Constants::STR_UNABLE_TO_LISTEN);
            static QString debuggingNotEnabled = QLatin1String(Constants::STR_IGNORING_DEBUGGER);
            static QString debuggingNotEnabled2 = QLatin1String(Constants::STR_IGNORING_DEBUGGER2);
            static QString connectionEstablished = QLatin1String(Constants::STR_CONNECTION_ESTABLISHED);

            if (status.startsWith(waitingForConnection)) {
                status.remove(0, waitingForConnection.size()); // chop of 'Waiting for connection '

                static QRegExp waitingTcp(
                            QString::fromLatin1(Constants::STR_ON_PORT_PATTERN));
                if (waitingTcp.indexIn(status) > -1) {
                    bool canConvert;
                    quint16 port = waitingTcp.cap(1).toUShort(&canConvert);
                    if (canConvert)
                        emit waitingForConnectionOnPort(port);
                    continue;
                }
            } else if (status.startsWith(unableToListen)) {
                //: Error message shown after 'Could not connect ... debugger:"
                emit errorMessage(tr("The port seems to be in use."));
            } else if (status.startsWith(debuggingNotEnabled) || status.startsWith(debuggingNotEnabled2)) {
                //: Error message shown after 'Could not connect ... debugger:"
                emit errorMessage(tr("The application is not set up for QML/JS debugging."));
            } else if (status.startsWith(connectionEstablished)) {
                emit connectionEstablishedMessage();
            } else {
                emit unknownMessage(status);
            }
        } else if (msg.contains(m_noOutputText)) {
            emit noOutputMessage();
        }


    }
}
Ejemplo n.º 21
0
void PropagateUploadFileQNAM::slotPutFinished()
{
    PUTFileJob *job = qobject_cast<PUTFileJob *>(sender());
    Q_ASSERT(job);
    slotJobDestroyed(job); // remove it from the _jobs list

    qDebug() << Q_FUNC_INFO << job->reply()->request().url() << "FINISHED WITH STATUS"
             << job->reply()->error()
             << (job->reply()->error() == QNetworkReply::NoError ? QLatin1String("") : job->reply()->errorString())
             << job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute)
             << job->reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute);

    _propagator->_activeJobList.removeOne(this);

    if (_finished) {
        // We have sent the finished signal already. We don't need to handle any remaining jobs
        return;
    }

    QNetworkReply::NetworkError err = job->reply()->error();

#if QT_VERSION < QT_VERSION_CHECK(5, 4, 2)
    if (err == QNetworkReply::OperationCanceledError && job->reply()->property(owncloudShouldSoftCancelPropertyName).isValid()) {
        // Abort the job and try again later.
        // This works around a bug in QNAM wich might reuse a non-empty buffer for the next request.
        qDebug() << "Forcing job abort on HTTP connection reset with Qt < 5.4.2.";
        _propagator->_anotherSyncNeeded = true;
        abortWithError(SyncFileItem::SoftError, tr("Forcing job abort on HTTP connection reset with Qt < 5.4.2."));
        return;
    }
#endif

    if (err != QNetworkReply::NoError) {
        _item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
        if(checkForProblemsWithShared(_item->_httpErrorCode,
            tr("The file was edited locally but is part of a read only share. "
               "It is restored and your edit is in the conflict file."))) {
            return;
        }
        QByteArray replyContent = job->reply()->readAll();
        qDebug() << replyContent; // display the XML error in the debug
        QString errorString = errorMessage(job->errorString(), replyContent);

        if (job->reply()->hasRawHeader("OC-ErrorString")) {
            errorString = job->reply()->rawHeader("OC-ErrorString");
        }

        if (_item->_httpErrorCode == 412) {
            // Precondition Failed:   Maybe the bad etag is in the database, we need to clear the
            // parent folder etag so we won't read from DB next sync.
            _propagator->_journal->avoidReadFromDbOnNextSync(_item->_file);
            _propagator->_anotherSyncNeeded = true;
        }

        SyncFileItem::Status status = classifyError(err, _item->_httpErrorCode,
                                                    &_propagator->_anotherSyncNeeded);
        abortWithError(status, errorString);
        return;
    }

    _item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
    // The server needs some time to process the request and provide us with a poll URL
    if (_item->_httpErrorCode == 202) {
        _finished = true;
        QString path =  QString::fromUtf8(job->reply()->rawHeader("OC-Finish-Poll"));
        if (path.isEmpty()) {
            done(SyncFileItem::NormalError, tr("Poll URL missing"));
            return;
        }
        startPollJob(path);
        return;
    }

    // Check the file again post upload.
    // Two cases must be considered separately: If the upload is finished,
    // the file is on the server and has a changed ETag. In that case,
    // the etag has to be properly updated in the client journal, and because
    // of that we can bail out here with an error. But we can reschedule a
    // sync ASAP.
    // But if the upload is ongoing, because not all chunks were uploaded
    // yet, the upload can be stopped and an error can be displayed, because
    // the server hasn't registered the new file yet.
    QByteArray etag = getEtagFromReply(job->reply());
    bool finished = etag.length() > 0;

    // Check if the file still exists
    const QString fullFilePath(_propagator->getFilePath(_item->_file));
    if( !FileSystem::fileExists(fullFilePath) ) {
        if (!finished) {
            abortWithError(SyncFileItem::SoftError, tr("The local file was removed during sync."));
            return;
        } else {
            _propagator->_anotherSyncNeeded = true;
        }
    }

    // Check whether the file changed since discovery.
    if (! FileSystem::verifyFileUnchanged(fullFilePath, _item->_size, _item->_modtime)) {
        _propagator->_anotherSyncNeeded = true;
        if( !finished ) {
            abortWithError(SyncFileItem::SoftError, tr("Local file changed during sync."));
            // FIXME:  the legacy code was retrying for a few seconds.
            //         and also checking that after the last chunk, and removed the file in case of INSTRUCTION_NEW
            return;
        }
    }

    if (!finished) {
        // Proceed to next chunk.
        if (_currentChunk >= _chunkCount) {
            if (!_jobs.empty()) {
                // just wait for the other job to finish.
                return;
            }
            _finished = true;
            done(SyncFileItem::NormalError, tr("The server did not acknowledge the last chunk. (No e-tag was present)"));
            return;
        }

        // Deletes an existing blacklist entry on successful chunk upload
        if (_item->_hasBlacklistEntry) {
            _propagator->_journal->wipeErrorBlacklistEntry(_item->_file);
            _item->_hasBlacklistEntry = false;
        }

        SyncJournalDb::UploadInfo pi;
        pi._valid = true;
        auto currentChunk = job->_chunk;
        foreach (auto *job, _jobs) {
            // Take the minimum finished one
            if (auto putJob = qobject_cast<PUTFileJob*>(job)) {
                currentChunk = qMin(currentChunk, putJob->_chunk - 1);
            }
        }
        pi._chunk = (currentChunk + _startChunk + 1) % _chunkCount ; // next chunk to start with
        pi._transferid = _transferId;
        pi._modtime =  Utility::qDateTimeFromTime_t(_item->_modtime);
        _propagator->_journal->setUploadInfo(_item->_file, pi);
        _propagator->_journal->commit("Upload info");
        startNextChunk();
        return;
    }

    // the following code only happens after all chunks were uploaded.
    _finished = true;
    // the file id should only be empty for new files up- or downloaded
    QByteArray fid = job->reply()->rawHeader("OC-FileID");
    if( !fid.isEmpty() ) {
        if( !_item->_fileId.isEmpty() && _item->_fileId != fid ) {
            qDebug() << "WARN: File ID changed!" << _item->_fileId << fid;
        }
        _item->_fileId = fid;
    }

    _item->_etag = etag;

    _item->_responseTimeStamp = job->responseTimestamp();

    if (job->reply()->rawHeader("X-OC-MTime") != "accepted") {
        // X-OC-MTime is supported since owncloud 5.0.   But not when chunking.
        // Normally Owncloud 6 always puts X-OC-MTime
        qWarning() << "Server does not support X-OC-MTime" << job->reply()->rawHeader("X-OC-MTime");
        // Well, the mtime was not set
        done(SyncFileItem::SoftError, "Server does not support X-OC-MTime");
    }

    // performance logging
    _item->_requestDuration = _stopWatch.stop();
    qDebug() << "*==* duration UPLOAD" << _item->_size
             << _stopWatch.durationOfLap(QLatin1String("ContentChecksum"))
             << _stopWatch.durationOfLap(QLatin1String("TransmissionChecksum"))
             << _item->_requestDuration;

    finalize(*_item);
}
Ejemplo n.º 22
0
void SanyoDVD1::populateProtocol(
  QObject *guiObject)
{
  if (threadableProtocol)
  {
    // If the pointer is not null, the keyset must already be populated.
    return;
  }

  threadableProtocol = new NECProtocol(guiObject, index, true, true);

  connect(
    threadableProtocol,
    SIGNAL(errorMessage(QString)),
    this,
    SIGNAL(errorMessage(QString)));

//  setPreData(0x3C23, 16);
  setPreData(0xC43C, 16);

  addKey("On", Power_Key, 0x00, 8);
  addKey("OpenClose", Eject_Key, 0x01, 8);
  addKey("Setup", Menu_Key, 0x02, 8);
  addKey("OnScreen", Unmapped_Key, 0x03, 8);
  addKey("SubtitleChange", Unmapped_Key, 0x05, 8);
  addKey("TopMenu", DiscTitle_Key, 0x06, 8);
  addKey("Menu", DiscMenu_Key, 0x07, 8);
  addKey("Angle", Angle_Key, 0x08, 8);
  addKey("AngleReplay", Unmapped_Key, 0x09, 8);
  addKey("Audio", Audio_Key, 0x0A, 8);
  addKey("Up", Up_Key, 0x0B, 8);
  addKey("Down", Down_Key, 0x0C, 8);
  addKey("Left", Left_Key, 0x0D, 8);
  addKey("Right", Right_Key, 0x0E, 8);
  addKey("Enter", Select_Key, 0x0F, 8);
  addKey("Return", Exit_Key, 0x10, 8);
  addKey("1", One_Key, 0x11, 8);
  addKey("2", Two_Key, 0x12, 8);
  addKey("3", Three_Key, 0x13, 8);
  addKey("4", Four_Key, 0x14, 8);
  addKey("5", Five_Key, 0x15, 8);
  addKey("6", Six_Key, 0x16, 8);
  addKey("7", Seven_Key, 0x17, 8);
  addKey("8", Eight_Key, 0x18, 8);
  addKey("9", Nine_Key, 0x19, 8);
  addKey("0", Zero_Key, 0x1A, 8);
  addKey("Clear", Clear_Key, 0x1C, 8);
  addKey("Stop", Stop_Key, 0x1E, 8);
  addKey("Play", Play_Key, 0x1F, 8);
  addKey("PauseStep", Pause_Key, 0x20, 8);
  addKey("Next", Next_Key, 0x21, 8);
  addKey("Prev", Previous_Key, 0x22, 8);
  addKey("Fwd", FastForward_Key, 0x23, 8);
  addKey("Rev", Rewind_Key, 0x26, 8);
  addKey("FwdSlow", StepForward_Key, 0x29, 8);
  addKey("RevSlow", StepBack_Key, 0x2C, 8);
  addKey("LastMemo", Unmapped_Key, 0x2F, 8);
  addKey("Repeat", Repeat_Key, 0x35, 8);
  addKey("ABRepeat", RepeatAB_Key, 0x36, 8);
  addKey("SearchMode", Unmapped_Key, 0x38, 8);
  addKey("ProgramRandom", Random_Key, 0x39, 8);
  addKey("PictureMode", PictureMode_Key, 0x3A, 8);
  addKey("Zoom", Zoom_Key, 0x3B, 8);
  addKey("SubtitleOnOff", Captions_Key, 0x4A, 8);
}
Ejemplo n.º 23
0
bool OscapScannerBase::checkPrerequisites()
{
    if (!mCapabilities.baselineSupport())
    {
        emit errorMessage(
            QObject::tr("oscap tool doesn't support basic features required for workbench. "
                "Please make sure you have openscap 0.8.0 or newer. "
                "oscap version was detected as '%1'.").arg(mCapabilities.getOpenSCAPVersion())
        );

        return false;
    }

    if (mScannerMode == SM_SCAN_ONLINE_REMEDIATION && !mCapabilities.onlineRemediation())
    {
        emit errorMessage(
            QObject::tr("oscap tool doesn't support online remediation. "
                "Please make sure you have openscap 0.9.5 or newer if you want "
                "to use online remediation. "
                "oscap version was detected as '%1'.").arg(mCapabilities.getOpenSCAPVersion())
        );

        return false;
    }

    if (mScannerMode == SM_OFFLINE_REMEDIATION && !mCapabilities.ARFInput())
    {
        emit errorMessage(
            QObject::tr("oscap tool doesn't support taking ARFs (result datastreams) as input. "
                "Please make sure you have openscap <NOT IMPLEMENTED YET> or newer if you want "
                "to use offline remediation. "
                "oscap version was detected as '%1'.").arg(mCapabilities.getOpenSCAPVersion())
        );

        return false;
    }

    if (mSession->isSDS() && !mCapabilities.sourceDatastreams())
    {
        emit errorMessage(
            QObject::tr("oscap tool doesn't support source datastreams as input. "
                "Please make sure you have openscap 0.9.0 or newer if you want "
                "to use source datastreams. "
                "oscap version was detected as '%1'.").arg(mCapabilities.getOpenSCAPVersion())
        );

        return false;
    }

    if (mSession->hasTailoring() && !mCapabilities.tailoringSupport())
    {
        emit errorMessage(
            QObject::tr("oscap tool doesn't support XCCDF tailoring but the session uses tailoring. "
                "Please make sure you have openscap 0.9.12 or newer on the target machine if you "
                "want to use tailoring features of SCAP Workbench. "
                "oscap version was detected as '%1'.").arg(mCapabilities.getOpenSCAPVersion())
        );

        return false;
    }

    return true;
}
Ejemplo n.º 24
0
void SanyoTV1::populateProtocol(
  QObject *guiObject)
{
  if (threadableProtocol)
  {
    // If the pointer is not null, the keyset must already be populated.
    return;
  }

  threadableProtocol = new NECProtocol(guiObject, index, false, true);

  connect(
    threadableProtocol,
    SIGNAL(errorMessage(QString)),
    this,
    SIGNAL(errorMessage(QString)));

  setPreData(0x38, 8);

  addKey("0", Zero_Key, 0x00, 8);
  addKey("1", One_Key, 0x01, 8);
  addKey("2", Two_Key, 0x02, 8);
  addKey("3", Three_Key, 0x03, 8);
  addKey("4", Four_Key, 0x04, 8);
  addKey("5", Five_Key, 0x05, 8);
  addKey("6", Six_Key, 0x06, 8);
  addKey("7", Seven_Key, 0x07, 8);
  addKey("8", Eight_Key, 0x08, 8);
  addKey("9", Nine_Key, 0x09, 8);
  addKey("Channel Up", ChannelUp_Key, 0x0A, 8);
  addKey("Channel Down", ChannelDown_Key, 0x0B, 8);
  addKey("Display", Info_Key, 0x0C, 8);
  addKey("Sleep", Sleep_Key, 0x0D, 8);
  addKey("Volume Up", VolumeUp_Key, 0x0E, 8);
  addKey("Volume Down", VolumeDown_Key, 0x0F, 8);
  addKey("Closed Captions", Captions_Key, 0x11, 8);
  addKey("Power", Power_Key, 0x12, 8);
  addKey("Input", Input_Key, 0x13, 8); // "TV/AV"
  addKey("Surround Toggle", Surround_Key, 0x14, 8);
  addKey("Enter", Enter_Key, 0x15, 8); // odd
  addKey("DASH", Dash_Key, 0x15, 8);
  addKey("Menu", Menu_Key, 0x17, 8); // "setup"
  addKey("Mute", Mute_Key, 0x18, 8);
  addKey("Recall", PrevChannel_Key, 0x19, 8);
  addKey("audio", Audio_Key, 0x1A, 8); // My Sanyo has this mapping
//  addKey("audio", SoundMode_Key, 0x1A, 8); // Other Sanyos have this one?
//  addKey("CC", Captions_Key, 0x1B, 8); // ?
  addKey("reset", Reset_Key, 0x1C, 8); // picture adjustment
  addKey("select", Select_Key, 0x1D, 8);
  addKey("right arrow", Right_Key, 0x1E, 8);
  addKey("left arrow", Left_Key, 0x1F, 8);
  addKey("V-guide menu", Guide_Key, 0x4C, 8);
  addKey("up arrow", Up_Key, 0x4E, 8);
  addKey("down arrow", Down_Key, 0x4F, 8);
  addKey("exit", Exit_Key, 0x53, 8);
//  addKey("enter", Select_Key, 0x54, 8);
  addKey("tuner", ADTunerSwap_Key, 0x55, 8); // "Tuner Toggle (analog-digital)"
//  addKey("+100", PlusOneHundred_Key, 0x55, 8);
  addKey("pix shape", AspectRatio_Key, 0x57, 8);
  addKey("pip up", Unmapped_Key, 0x59, 8);
  addKey("pip down", Unmapped_Key, 0x5A, 8);
  addKey("PIP", PIP_Key, 0x5B, 8);
  addKey("Swap", PIPSwap_Key, 0x5D, 8);
  addKey("freeze", PIPPause_Key, 0x5E, 8);
  addKey("DISCRETE OFF", PowerOff_Key, 0x76, 8);
  addKey("Volume Cycle (Max/Min/Normal)", Unmapped_Key, 0x80, 8);
  addKey("puts 'A' on the screen", Unmapped_Key, 0x81, 8);
  addKey("puts 'P' on the screen", Unmapped_Key, 0x82, 8);
  addKey("Scan Velocity Cycle (Hi/Lo/Off)", Unmapped_Key, 0x87, 8);
  addKey("Color Cycle", ColorUp_Key, 0x88, 8);
  addKey("Tint Cycle", Unmapped_Key, 0x89, 8);
  addKey("Contrast Cycle", ContrastUp_Key, 0x8A, 8);
  addKey("Brightness Cycle", BrightnessUp_Key, 0x8B, 8);
  addKey("Sharpness Cycle", Unmapped_Key, 0x8C, 8);
  addKey("bass", BassUp_Key, 0x8E, 8);
  addKey("Treble", TrebleUp_Key, 0x8F, 8);
  addKey("Service Menu", ServiceMenu_Key, 0x91, 8);
  addKey("Crude Info", Unmapped_Key, 0x96, 8);
  addKey("Video 1", ComponentInput_Key, 0x97, 8);
  addKey("Color Enhancer Cycle (Normal/Warm/Cool)", Unmapped_Key, 0x98, 8);
  addKey("Video 3", MDInput_Key, 0x99, 8); // hack
  addKey("Video 2", Component2Input_Key, 0x9C, 8);
  addKey("HDMI 1", HDMIInput_Key, 0x9D, 8); // "Speaker Toggle"
  addKey("HDMI 2", HDMI2Input_Key, 0x9E, 8);
  addKey("puts 'R32 B26' on the screen.  MENU cancels.", Unmapped_Key, 0x9F, 8);
  addKey("Reset?", FactoryReset_Key, 0xC0, 8);
  addKey("Clear?", Unmapped_Key, 0xC1, 8); // System Info
  addKey("DISPLAY PARAMETERS", Unmapped_Key, 0xC2, 8);
  addKey("Self Test", Unmapped_Key, 0xC3, 8);

//  addKey("Black screen (recoverable with 0x9F then MENU)", Unmapped_Key, 0x9E, 8);
}
Ejemplo n.º 25
0
void FortecReceiver2::populateProtocol(
  QObject *guiObject)
{
  if (threadableProtocol)
  {
    // If the pointer is not null, the keyset must already be populated.
    return;
  }

  threadableProtocol = new NECProtocol(guiObject, index, true, true);

  connect(
    threadableProtocol,
    SIGNAL(errorMessage(QString)),
    this,
    SIGNAL(errorMessage(QString)));

  setPreData(0xFD01, 16);

  addKey("channel up", ChannelUp_Key, 0x00, 8); // "up arrow"
  addKey("channel up", Up_Key, 0x00, 8); // "up arrow"
  addKey("channel down", ChannelDown_Key, 0x01, 8); // "down arrow"
  addKey("channel down", Down_Key, 0x01, 8); // "down arrow"
  addKey("vol_up", VolumeUp_Key, 0x02, 8); // "right arrow"
  addKey("vol_up", Right_Key, 0x02, 8); // "right arrow"
  addKey("vol_down", VolumeDown_Key, 0x03, 8); // "left arrow"
  addKey("vol_down", Left_Key, 0x03, 8); // "left arrow"
  addKey("tv_dbs", Input_Key, 0x04, 8);
  addKey("menu", Menu_Key, 0x05, 8);
  addKey("tv_radio", TunerInput_Key, 0x06, 8);
  addKey("power_scan", Scan_Key, 0x08, 8);
  addKey("green", Green_Key, 0x09, 8); // "zoom"
  addKey("green", Zoom_Key, 0x09, 8); // "zoom"
  addKey("power", Power_Key, 0x0A, 8);
  addKey("recall", PrevChannel_Key, 0x0B, 8);
  addKey("mute", Mute_Key, 0x0C, 8);
  addKey("scroll_down", PageDown_Key, 0x0D, 8);
  addKey("audio", Audio_Key, 0x0E, 8);
  addKey("multi", Unmapped_Key, 0x0F, 8);

  addKey("0", Zero_Key, 0x10, 8);
  addKey("1", One_Key, 0x11, 8);
  addKey("2", Two_Key, 0x12, 8);
  addKey("3", Three_Key, 0x13, 8);
  addKey("4", Four_Key, 0x14, 8);
  addKey("5", Five_Key, 0x15, 8);
  addKey("6", Six_Key, 0x16, 8);
  addKey("7", Seven_Key, 0x17, 8);
  addKey("8", Eight_Key, 0x18, 8);
  addKey("9", Nine_Key, 0x19, 8);
  addKey("sat", Unmapped_Key, 0x1A, 8);
  addKey("sig", Unmapped_Key, 0x1B, 8);
  addKey("pic", Unmapped_Key, 0x1C, 8);
  addKey("display", Info_Key, 0x1D, 8); // "info"
  addKey("red", Red_Key, 0x1E, 8); // "pause"
//  addKey("red", Pause_Key, 0x1E, 8); // "pause"
  addKey("select", Select_Key, 0x1F, 8); // "ok"

  addKey("rewind", Rewind_Key, 0x22, 8);
  addKey("play", Play_Key, 0x23, 8);
  addKey("stop", Stop_Key, 0x24, 8);
  addKey("fast_forward", FastForward_Key, 0x25, 8);
  addKey("pause", Pause_Key, 0x28, 8);

  addKey("fav", Favorites_Key, 0x40, 8);
  addKey("yellow", Yellow_Key, 0x41, 8); // "calendar"
  addKey("edit", Unmapped_Key, 0x42, 8);
  addKey("timer", Timer_Key, 0x43, 8);
  addKey("program guide", Guide_Key, 0x45, 8);
  addKey("record", Record_Key, 0x46, 8);
  addKey("find", Unmapped_Key, 0x47, 8);
  addKey("exit", Exit_Key, 0x48, 8);
  addKey("scroll_up", PageUp_Key, 0x49, 8);

  addKey("back", Replay_Key, 0x50, 8);
  addKey("fwd", Advance_Key, 0x51, 8);
}
Ejemplo n.º 26
0
// Note: Same device ID as keyset 1, but very different commands!!!
void SanyoTV2::populateProtocol(
  QObject *guiObject)
{
  if (threadableProtocol)
  {
    // If the pointer is not null, the keyset must already be populated.
    return;
  }

  threadableProtocol = new NECProtocol(guiObject, index, false, true);

  connect(
    threadableProtocol,
    SIGNAL(errorMessage(QString)),
    this,
    SIGNAL(errorMessage(QString)));

  setPreData(0x38, 8);

  addKey("0", Zero_Key, 0x00, 8);
  addKey("1", One_Key, 0x01, 8);
  addKey("2", Two_Key, 0x02, 8);
  addKey("3", Three_Key, 0x03, 8);
  addKey("4", Four_Key, 0x04, 8);
  addKey("5", Five_Key, 0x05, 8);
  addKey("6", Six_Key, 0x06, 8);
  addKey("7", Seven_Key, 0x07, 8);
  addKey("8", Eight_Key, 0x08, 8);
  addKey("9", Nine_Key, 0x09, 8);
  addKey("-/--", DoubleDigit_Key, 0x0A, 8);
  addKey("CS", Unmapped_Key, 0x0B, 8); // 2-
  addKey("P+", ChannelUp_Key, 0x0C, 8);
  addKey("UP", Up_Key, 0x0C, 8);
  addKey("P-", ChannelDown_Key, 0x0D, 8);
  addKey("DOWN", Down_Key, 0x0D, 8);
  addKey("contrast_>", ContrastUp_Key, 0x0E, 8);
  addKey("contrast_<", ContrastDown_Key, 0x0F, 8);
  addKey("prg_scan", Scan_Key, 0x10, 8);
  addKey("NORMAL", Unmapped_Key, 0x11, 8); // "SYMBOL_2"
  addKey("tuning_>", ChannelUp_Key, 0x12, 8);
  addKey("tuning_<", ChannelDown_Key, 0x13, 8);
  addKey("tv/av", Input_Key, 0x14, 8);
  addKey("MUTE", Mute_Key, 0x15, 8);
  addKey("VOL+", VolumeUp_Key, 0x16, 8);
  addKey("RIGHT", Right_Key, 0x16, 8);
  addKey("VOL-", VolumeDown_Key, 0x17, 8);
  addKey("LEFT", Left_Key, 0x17, 8);
  addKey("OSD", Info_Key, 0x18, 8); // "SYMBOL_1", "status"
  addKey("RECALL/TEXT_REVEAL", TeletextReveal_Key, 0x18, 8);
  addKey("clear_screen", Unmapped_Key, 0x18, 8);
  addKey("CLOCK", Sleep_Key, 0x19, 8); // "SLEEP/ON-TIMER/TEXT_CANCEL"
//  addKey("ok", Select_Key, 0x1A, 8);
  addKey("colour_>", ColorUp_Key, 0x1A, 8);
  addKey("colour_<", ColorDown_Key, 0x1B, 8);
  addKey("POWER", Power_Key, 0x1C, 8);
  addKey("P--P", PrevChannel_Key, 0x1D, 8); // "ALTERNATE"
  addKey("bright_>", BrightnessUp_Key, 0x1E, 8);
  addKey("bright_<", BrightnessDown_Key, 0x1F, 8);
  addKey("A-B", Unmapped_Key, 0x40, 8); //?
  addKey("WIDE", Unmapped_Key, 0x43, 8);
  addKey("TXT/TV", Teletext_Key, 0x46, 8); // teletext
  addKey("Red", Red_Key, 0x49, 8); // surround
  addKey("Green", Green_Key, 0x4A, 8);
  addKey("Yellow", Yellow_Key, 0x4B, 8); // bass
  addKey("Blue", Blue_Key, 0x4C, 8); // time
  addKey("TEXT_HOLD", TeletextHold_Key, 0x4E, 8); // "SHRINK"
  addKey("TEXT_INDEX-PAGE", TeletextIndex_Key, 0x51, 8);
  addKey("MENU", Menu_Key, 0x51, 8);
  addKey("TEXT_SIZE", TeletextSize_Key, 0x56, 8); // "EXPAND"
  addKey("AV1", CompositeInput_Key, 0xD8, 8);
}
Ejemplo n.º 27
0
// Note: the phase input is currently not supported
void CoolPropSolver::setState_ph(double &p, double &h, int &phase, ExternalThermodynamicState *const properties){

	if (debug_level > 5)
		std::cout << format("setState_ph(p=%0.16e,h=%0.16e)\n",p,h);

	if (enable_TTSE)
		state->enable_TTSE_LUT();
	else
		state->disable_TTSE_LUT();
	try{
		// Update the internal variables in the state instance
		state->update(iP,p,iH,h);
		
		if (!ValidNumber(state->rho()) || !ValidNumber(state->T()))
		{
			throw ValueError(format("p-h [%g, %g] failed for update",p,h));
		}
		// Set the values in the output structure
		properties->p = p;
		properties->h = h;

		properties->d = state->rho();
		properties->T = state->T();
		properties->s = state->s();
		
		if (state->TwoPhase){
			properties->phase = 2; 
		}
		else{
			properties->phase = 1; 
		}
		properties->cp = state->cp();
		properties->cv = state->cv();
		properties->a = state->speed_sound();
		if (state->TwoPhase && state->Q() >= 0 && state->Q() <= twophase_derivsmoothing_xend)
		{
			// Use the smoothed derivatives between a quality of 0 and twophase_derivsmoothing_xend
			properties->ddhp = state->drhodh_constp_smoothed(twophase_derivsmoothing_xend); // [1/kPa -- > 1/Pa]
			properties->ddph = state->drhodp_consth_smoothed(twophase_derivsmoothing_xend); // [1/(kJ/kg) -- > 1/(J/kg)]
		} 
		else if (state->TwoPhase && state->Q() >= 0 && state->Q() <= rho_smoothing_xend)
		{
			// Use the smoothed density between a quality of 0 and rho_smoothing_xend 
			double rho_spline;
			double dsplinedh;
			double dsplinedp;
			state->rho_smoothed(rho_smoothing_xend, &rho_spline, &dsplinedh, &dsplinedp) ;
            properties->ddhp = dsplinedh;
            properties->ddph = dsplinedp;
			properties->d = rho_spline;
		}
		else
		{
            properties->ddhp = state->drhodh_constp();
			properties->ddph = state->drhodp_consth();
		}
		properties->kappa = state->isothermal_compressibility();
		properties->beta = state->isobaric_expansion_coefficient();

		if (calc_transport)
        {
            properties->eta = state->viscosity();
            properties->lambda = state->conductivity(); //[kW/m/K --> W/m/K]
            properties->Pr = properties->cp*properties->eta/properties->lambda;
        }
	}
	catch(std::exception &e)
	{
		errorMessage((char*)e.what());
	}
}
Ejemplo n.º 28
0
void SanyoVCR1::populateProtocol(
  QObject *guiObject)
{
  if (threadableProtocol)
  {
    // If the pointer is not null, the keyset must already be populated.
    return;
  }

  threadableProtocol = new NECProtocol(guiObject, index, false, true);

  connect(
    threadableProtocol,
    SIGNAL(errorMessage(QString)),
    this,
    SIGNAL(errorMessage(QString)));

//  setPreData(0x8C73, 16);
  setPreData(0x31, 8);

  addKey("Ch Up", ChannelUp_Key, 0x01, 8);
  addKey("Ch Down", ChannelDown_Key, 0x02, 8);
  addKey("Audio", Audio_Key, 0x03, 8);
  addKey("1", One_Key, 0x04, 8);
  addKey("2", Two_Key, 0x05, 8);
  addKey("3", Three_Key, 0x06, 8);
  addKey("4", Four_Key, 0x07, 8);
  addKey("TV/VCR", Input_Key, 0x08, 8);
  addKey("x2", PlayX2_Key, 0x0B, 8);
  addKey("5", Five_Key, 0x0C, 8);
  addKey("6", Six_Key, 0x0D, 8);
  addKey("7", Seven_Key, 0x0E, 8);
  addKey("8", Eight_Key, 0x0F, 8);
  addKey("Stop", Stop_Key, 0x10, 8);
  addKey("Pause", Pause_Key, 0x11, 8);
  addKey("Rew", Rewind_Key, 0x12, 8);
  addKey("FF", FastForward_Key, 0x13, 8);
  addKey("Play", Play_Key, 0x14, 8);
  addKey("Rec", Record_Key, 0x15, 8);
  addKey("Index", IndexSearch_Key, 0x19, 8);
  addKey("Slow", Slow_Key, 0x1A, 8);
  addKey("+100", PlusOneHundred_Key, 0x1B, 8);
  addKey("9", Nine_Key, 0x1C, 8);
  addKey("0", Zero_Key, 0x1D, 8);
  addKey("Input", Unmapped_Key, 0x1E, 8);  // need a subclass for this?
  addKey("ATR", AutoTracking_Key, 0x1F, 8);
  addKey("Memory", Memory_Key, 0x43, 8); // "->0<-"
  addKey("Reset", Reset_Key, 0x44, 8);
  addKey("PROG", Program_Key, 0x46, 8);
  addKey("Cancel", Clear_Key, 0x4A, 8);
  addKey("Ok", Select_Key, 0x4B, 8);
  addKey("Display", Info_Key, 0x4C, 8);
  addKey("VPS", RecordPDC_Key, 0x4F, 8); // "vps/pdc", "dpc"
  addKey("Monitor", Unmapped_Key, 0x51, 8);
  addKey("Clock", Clock_Key, 0x56, 8);
  addKey("Power", Power_Key, 0x5B, 8);
  addKey("SP/LP", VHSSpeed_Key, 0x5E, 8);
  addKey("ShowView", Unmapped_Key, 0x8C, 8); // vhsplus+, etc.
  addKey("Right", Right_Key, 0x94, 8);
  addKey("Left", Left_Key, 0x95, 8);
  addKey("Down", Down_Key, 0x96, 8);
  addKey("Up", Up_Key, 0x97, 8);
  addKey("Preset", Unmapped_Key, 0x9E, 8);
  addKey("Menu", Menu_Key, 0xCA, 8);
  addKey("BLANK", Unmapped_Key, 0xD0, 8);
}
Ejemplo n.º 29
0
double CoolPropSolver::hl(ExternalSaturationProperties *const properties){
    // Base function returns an error if called - should be redeclared by the solver object
	errorMessage((char*)"Internal error: hl() not implemented in the Solver object");
	throw NotImplementedError((char*)"Internal error: hl() not implemented in the Solver object");
	return 0;
}
Ejemplo n.º 30
0
Dialog::Dialog(QWidget *parent)
    : QWidget(parent)
{
    errorMessageDialog = new QErrorMessage(this);

    int frameStyle = QFrame::Sunken | QFrame::Panel;

    integerLabel = new QLabel;
    integerLabel->setFrameStyle(frameStyle);
    QPushButton *integerButton =
        new QPushButton(tr("QInputDialog::get&Int()"));

    doubleLabel = new QLabel;
    doubleLabel->setFrameStyle(frameStyle);
    QPushButton *doubleButton =
        new QPushButton(tr("QInputDialog::get&Double()"));

    itemLabel = new QLabel;
    itemLabel->setFrameStyle(frameStyle);
    QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()"));

    textLabel = new QLabel;
    textLabel->setFrameStyle(frameStyle);
    QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()"));

    colorLabel = new QLabel;
    colorLabel->setFrameStyle(frameStyle);
    QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()"));

    fontLabel = new QLabel;
    fontLabel->setFrameStyle(frameStyle);
    QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()"));

    directoryLabel = new QLabel;
    directoryLabel->setFrameStyle(frameStyle);
    QPushButton *directoryButton =
        new QPushButton(tr("QFileDialog::getE&xistingDirectory()"));

    openFileNameLabel = new QLabel;
    openFileNameLabel->setFrameStyle(frameStyle);
    QPushButton *openFileNameButton =
        new QPushButton(tr("QFileDialog::get&OpenFileName()"));

    openFileNamesLabel = new QLabel;
    openFileNamesLabel->setFrameStyle(frameStyle);
    QPushButton *openFileNamesButton =
        new QPushButton(tr("QFileDialog::&getOpenFileNames()"));

    saveFileNameLabel = new QLabel;
    saveFileNameLabel->setFrameStyle(frameStyle);
    QPushButton *saveFileNameButton =
        new QPushButton(tr("QFileDialog::get&SaveFileName()"));

    criticalLabel = new QLabel;
    criticalLabel->setFrameStyle(frameStyle);
    QPushButton *criticalButton =
        new QPushButton(tr("QMessageBox::critica&l()"));

    informationLabel = new QLabel;
    informationLabel->setFrameStyle(frameStyle);
    QPushButton *informationButton =
        new QPushButton(tr("QMessageBox::i&nformation()"));

    questionLabel = new QLabel;
    questionLabel->setFrameStyle(frameStyle);
    QPushButton *questionButton =
        new QPushButton(tr("QMessageBox::&question()"));

    warningLabel = new QLabel;
    warningLabel->setFrameStyle(frameStyle);
    QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()"));

    errorLabel = new QLabel;
    errorLabel->setFrameStyle(frameStyle);
    QPushButton *errorButton =
        new QPushButton(tr("QErrorMessage::showM&essage()"));

    connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger()));
    connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble()));
    connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem()));
    connect(textButton, SIGNAL(clicked()), this, SLOT(setText()));
    connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
    connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont()));
    connect(directoryButton, SIGNAL(clicked()),
            this, SLOT(setExistingDirectory()));
    connect(openFileNameButton, SIGNAL(clicked()),
            this, SLOT(setOpenFileName()));
    connect(openFileNamesButton, SIGNAL(clicked()),
            this, SLOT(setOpenFileNames()));
    connect(saveFileNameButton, SIGNAL(clicked()),
            this, SLOT(setSaveFileName()));
    connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage()));
    connect(informationButton, SIGNAL(clicked()),
            this, SLOT(informationMessage()));
    connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage()));
    connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage()));
    connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage()));

    native = new QCheckBox(this);
    native->setText("Use native file dialog.");
    native->setChecked(true);

    QGridLayout *layout = new QGridLayout;
    layout->setColumnStretch(1, 1);
    layout->setColumnMinimumWidth(1, 250);
    layout->addWidget(integerButton, 0, 0);
    layout->addWidget(integerLabel, 0, 1);
    layout->addWidget(doubleButton, 1, 0);
    layout->addWidget(doubleLabel, 1, 1);
    layout->addWidget(itemButton, 2, 0);
    layout->addWidget(itemLabel, 2, 1);
    layout->addWidget(textButton, 3, 0);
    layout->addWidget(textLabel, 3, 1);
    layout->addWidget(colorButton, 4, 0);
    layout->addWidget(colorLabel, 4, 1);
    layout->addWidget(fontButton, 5, 0);
    layout->addWidget(fontLabel, 5, 1);
    layout->addWidget(directoryButton, 6, 0);
    layout->addWidget(directoryLabel, 6, 1);
    layout->addWidget(openFileNameButton, 7, 0);
    layout->addWidget(openFileNameLabel, 7, 1);
    layout->addWidget(openFileNamesButton, 8, 0);
    layout->addWidget(openFileNamesLabel, 8, 1);
    layout->addWidget(saveFileNameButton, 9, 0);
    layout->addWidget(saveFileNameLabel, 9, 1);
    layout->addWidget(criticalButton, 10, 0);
    layout->addWidget(criticalLabel, 10, 1);
    layout->addWidget(informationButton, 11, 0);
    layout->addWidget(informationLabel, 11, 1);
    layout->addWidget(questionButton, 12, 0);
    layout->addWidget(questionLabel, 12, 1);
    layout->addWidget(warningButton, 13, 0);
    layout->addWidget(warningLabel, 13, 1);
    layout->addWidget(errorButton, 14, 0);
    layout->addWidget(errorLabel, 14, 1);
    layout->addWidget(native, 15, 0);
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    QWidget *widget = new QWidget;
    widget->setLayout(layout);

    QScrollArea *scrollArea = new QScrollArea(this);
    scrollArea->setWidget(widget);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(scrollArea);
    setLayout(mainLayout);
#else
    setLayout(layout);
#endif

    setWindowTitle(tr("Standard Dialogs"));
}