Ejemplo n.º 1
0
void Window::vApplyConfigJoypads()
{
    for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++) {
        char csPrefix[20];
        snprintf(csPrefix, sizeof(csPrefix), "joypadSDL%d_", i);
        std::string sPrefix(csPrefix);

        for (guint j = 0; j < G_N_ELEMENTS(m_astJoypad); j++) {
            inputSetKeymap((EPad)i, m_astJoypad[j].m_eKeyFlag,
                m_poInputConfig->oGetKey<guint>(sPrefix + m_astJoypad[j].m_csKey));
        }
    }
}
Ejemplo n.º 2
0
void Window::vSaveJoypadsToConfig()
{
    for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++) {
        char csPrefix[20];
        snprintf(csPrefix, sizeof(csPrefix), "joypadSDL%d_", i);
        std::string sPrefix(csPrefix);

        for (guint j = 0; j < G_N_ELEMENTS(m_astJoypad); j++) {
            m_poInputConfig->vSetKey(sPrefix + m_astJoypad[j].m_csKey,
                inputGetKeymap((EPad)i, m_astJoypad[j].m_eKeyFlag));
        }
    }
}
Ejemplo n.º 3
0
    void newMessage(const SecMsgStored& inboxHdr)
    {
        // we have to copy it, because it doesn't like constants going into Decrypt
        SecMsgStored smsgStored = inboxHdr;
        MessageData msg;
        QString label;
        QDateTime sent_datetime;
        QDateTime received_datetime;

        uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN;
        if (SecureMsgDecrypt(false, smsgStored.sAddrTo, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0)
        {
            label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(msg.sFromAddress));

            sent_datetime    .setTime_t(msg.timestamp);
            received_datetime.setTime_t(smsgStored.timeReceived);

            std::string sPrefix("im");
            SecureMessage* psmsg = (SecureMessage*) &smsgStored.vchMessage[0];

            std::vector<unsigned char> vchKey;
            vchKey.resize(18);
            memcpy(&vchKey[0],  sPrefix.data(),  2);
            memcpy(&vchKey[2],  &psmsg->timestamp, 8);
            memcpy(&vchKey[10], &smsgStored.vchMessage[SMSG_HDR_LEN], 8);    // sample

            addMessageEntry(MessageTableEntry(vchKey,
                                              MessageTableEntry::Received,
                                              label,
                                              QString::fromStdString(smsgStored.sAddrTo),
                                              QString::fromStdString(msg.sFromAddress),
                                              sent_datetime,
                                              received_datetime,
                                              !(smsgStored.status & SMSG_MASK_UNREAD),
                                              (char*)&msg.vchMessage[0]),
                            false);
        }
    }
Ejemplo n.º 4
0
    void newOutboxMessage(const SecMsgStored& outboxHdr)
    {

        SecMsgStored smsgStored = outboxHdr;
        MessageData msg;
        QString label;
        QDateTime sent_datetime;
        QDateTime received_datetime;

        uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN;
        if (SecureMsgDecrypt(false, smsgStored.sAddrOutbox, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0)
        {
            label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(smsgStored.sAddrTo));

            sent_datetime    .setTime_t(msg.timestamp);
            received_datetime.setTime_t(smsgStored.timeReceived);

            std::string sPrefix("sm");
            SecureMessage* psmsg = (SecureMessage*) &smsgStored.vchMessage[0];
            std::vector<unsigned char> vchKey;
            vchKey.resize(18);
            memcpy(&vchKey[0],  sPrefix.data(),  2);
            memcpy(&vchKey[2],  &psmsg->timestamp, 8);
            memcpy(&vchKey[10], &smsgStored.vchMessage[SMSG_HDR_LEN], 8);    // sample

            addMessageEntry(MessageTableEntry(vchKey,
                                              MessageTableEntry::Sent,
                                              label,
                                              QString::fromStdString(smsgStored.sAddrTo),
                                              QString::fromStdString(msg.sFromAddress),
                                              sent_datetime,
                                              received_datetime,
                                              (char*)&msg.vchMessage[0]),
                            false);
        }
    }
Ejemplo n.º 5
0
void Window::vInitConfig()
{
    m_oConfig.vClear();

    // Directories section
    //
    m_poDirConfig = m_oConfig.poAddSection("Directories");
    m_poDirConfig->vSetKey("gb_roms", Glib::get_home_dir());
    m_poDirConfig->vSetKey("gba_roms", Glib::get_home_dir());
    m_poDirConfig->vSetKey("batteries", m_sUserDataDir);
    m_poDirConfig->vSetKey("cheats", m_sUserDataDir);
    m_poDirConfig->vSetKey("saves", m_sUserDataDir);
    m_poDirConfig->vSetKey("captures", m_sUserDataDir);

    // Core section
    //
    m_poCoreConfig = m_oConfig.poAddSection("Core");
    m_poCoreConfig->vSetKey("load_game_auto", false);
    m_poCoreConfig->vSetKey("frameskip", "auto");
    m_poCoreConfig->vSetKey("use_bios_file", false);
    m_poCoreConfig->vSetKey("bios_file", "");
    m_poCoreConfig->vSetKey("enable_rtc", false);
    m_poCoreConfig->vSetKey("save_type", SaveAuto);
    m_poCoreConfig->vSetKey("flash_size", 64);
    m_poCoreConfig->vSetKey("gb_border", false);
    m_poCoreConfig->vSetKey("gb_printer", false);
    m_poCoreConfig->vSetKey("gb_use_bios_file", false);
    m_poCoreConfig->vSetKey("gb_bios_file", "");
    m_poCoreConfig->vSetKey("emulator_type", EmulatorAuto);
    m_poCoreConfig->vSetKey("pause_when_inactive", true);
    m_poCoreConfig->vSetKey("show_speed", ShowPercentage);

    // Rewind
    //
    m_poCoreConfig->vSetKey("rewind_count_max", STATE_MAX_DEFAULT);
    m_poCoreConfig->vSetKey("rewind_interval", STATE_INTERVAL_DEFAULT);

    // Display section
    //
    m_poDisplayConfig = m_oConfig.poAddSection("Display");
    m_poDisplayConfig->vSetKey("scale", 1);
    m_poDisplayConfig->vSetKey("filter2x", FilterNone);
    m_poDisplayConfig->vSetKey("filterIB", FilterIBNone);
#if defined(USE_OPENGL) && !GTK_CHECK_VERSION(3, 0, 0)
    m_poDisplayConfig->vSetKey("output", OutputOpenGL);
#else
    m_poDisplayConfig->vSetKey("output", OutputCairo);
#endif // USE_OPENGL

    // Sound section
    //
    m_poSoundConfig = m_oConfig.poAddSection("Sound");
    m_poSoundConfig->vSetKey("mute", false);
    m_poSoundConfig->vSetKey("sample_rate", 44100);
    m_poSoundConfig->vSetKey("volume", 1.00f);

    // Input section
    //
    m_poInputConfig = m_oConfig.poAddSection("Input");
    m_poInputConfig->vSetKey("active_joypad", m_iJoypadMin);
    for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++) {
        char csPrefix[20];
        snprintf(csPrefix, sizeof(csPrefix), "joypadSDL%d_", i);
        std::string sPrefix(csPrefix);

        for (guint j = 0; j < G_N_ELEMENTS(m_astJoypad); j++) {
            m_poInputConfig->vSetKey(sPrefix + m_astJoypad[j].m_csKey,
                inputGetKeymap(PAD_DEFAULT, m_astJoypad[j].m_eKeyFlag));
        }
    }
}
Ejemplo n.º 6
0
    void refreshMessageTable()
    {
        cachedMessageTable.clear();
        
        if (parent->getWalletModel()->getEncryptionStatus() == WalletModel::Locked)
        {
            // -- messages are stored encrypted, can't load them without the private keys
            return;
        };

        {
            LOCK(cs_smsgDB);

            SecMsgDB dbSmsg;

            if (!dbSmsg.Open("cr+"))
                //throw runtime_error("Could not open DB.");
                return;

            unsigned char chKey[18];
            std::vector<unsigned char> vchKey;
            vchKey.resize(18);

            SecMsgStored smsgStored;
            MessageData msg;
            QString label;
            QDateTime sent_datetime;
            QDateTime received_datetime;

            std::string sPrefix("im");
            leveldb::Iterator* it = dbSmsg.pdb->NewIterator(leveldb::ReadOptions());
            while (dbSmsg.NextSmesg(it, sPrefix, chKey, smsgStored))
            {
                uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN;
                if (SecureMsgDecrypt(false, smsgStored.sAddrTo, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0)
                {
                    label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(msg.sFromAddress));

                    sent_datetime    .setTime_t(msg.timestamp);
                    received_datetime.setTime_t(smsgStored.timeReceived);
                    
                    memcpy(&vchKey[0], chKey, 18);

                    addMessageEntry(MessageTableEntry(vchKey,
                                                      MessageTableEntry::Received,
                                                      label,
                                                      QString::fromStdString(smsgStored.sAddrTo),
                                                      QString::fromStdString(msg.sFromAddress),
                                                      sent_datetime,
                                                      received_datetime,
                                                      (char*)&msg.vchMessage[0]),
                                    true);
                }
            };

            delete it;

            sPrefix = "sm";
            it = dbSmsg.pdb->NewIterator(leveldb::ReadOptions());
            while (dbSmsg.NextSmesg(it, sPrefix, chKey, smsgStored))
            {
                uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN;
                if (SecureMsgDecrypt(false, smsgStored.sAddrOutbox, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0)
                {
                    label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(smsgStored.sAddrTo));

                    sent_datetime    .setTime_t(msg.timestamp);
                    received_datetime.setTime_t(smsgStored.timeReceived);
                    
                    memcpy(&vchKey[0], chKey, 18);

                    addMessageEntry(MessageTableEntry(vchKey,
                                                      MessageTableEntry::Sent,
                                                      label,
                                                      QString::fromStdString(smsgStored.sAddrTo),
                                                      QString::fromStdString(msg.sFromAddress),
                                                      sent_datetime,
                                                      received_datetime,
                                                      (char*)&msg.vchMessage[0]),
                                    true);
                }
            };

            delete it;
        }
    }
Ejemplo n.º 7
0
UINT EnumDevices( CStdStrArray &devices, TCHAR * cPrefix )
{
  CStdString sPrefix( cPrefix );
  CStdString sCurrDev;
  int i=0;

  //Make sure we clear out any elements which may already be in the array
  devices.clear();

  //Determine what OS we are running on
  OSVERSIONINFO osvi;
  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  BOOL bGetVer = GetVersionEx(&osvi);

  //On NT use the QueryDosDevice API
  if (bGetVer && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT))
  {
    //Use QueryDosDevice to look for all devices of the form COMx. This is a better
    //solution as it means that no devices have to be opened at all.
    TCHAR szDevices[65535];
    DWORD dwChars = QueryDosDevice(NULL, szDevices, 65535);
    if (dwChars)
    {

      for (;;)
      {
        //Get the current device name
        TCHAR* pszCurrentDevice = &szDevices[i];
        sCurrDev = &szDevices[i];
        sCurrDev.ToUpper();


        //If it looks like "COMX" then
        //add it to the array which will be returned
        int nLen = sCurrDev.GetLength();
        if (nLen > sPrefix.GetLength() && _tcsnicmp(sCurrDev.c_str(), sPrefix.c_str() , sPrefix.GetLength() ) == 0)
        {
          //Work out the port number
          devices.push_back( CStdString(_T("\\\\.\\")) + CStdString( pszCurrentDevice ) );
        }

        // Go to next NULL character
        i+= sCurrDev.GetLength();
        //while(szDevices[i] != _T('\0'))
        //  i++;

        // Bump pointer to the next string
        i++;

        // The list is double-NULL terminated, so if the character is
        // now NULL, we're at the end
        if (szDevices[i] == _T('\0'))
          break;
      }
    }
    else
    {
      return -1;
    }
      
  }
  else
  {
    //On 95/98 open up each port to determine their existence

    //Up to 255 COM devices are supported so we iterate through all of them seeing
    //if we can open them or if we fail to open them, get an access denied or general error error.
    //Both of these cases indicate that there is a COM port at that number. 
    for (UINT i=1; i<256; i++)
    {
      //Form the Raw device name
      CStdString sDev;
      sDev.Format(_T("\\\\.\\%s%d"), sPrefix.c_str(), i);

      //Try to open the port
      BOOL bSuccess = FALSE;
      HANDLE hPort = ::CreateFile(sDev.c_str(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
      if (hPort == INVALID_HANDLE_VALUE)
      {
        DWORD dwError = GetLastError();

        //Check to see if the error was because some other app had the port open or a general failure
        if (dwError == ERROR_ACCESS_DENIED || dwError == ERROR_GEN_FAILURE)
          bSuccess = TRUE;
      }
      else
      {
        //The port was opened successfully
        bSuccess = TRUE;

        //Don't forget to close the port, since we are going to do nothing with it anyway
        CloseHandle(hPort);
      }

      //Add the port number to the array which will be returned
      if (bSuccess)
        devices.push_back(sDev.c_str());
    }
  }
  return devices.size();
}