Exemple #1
0
void doTest(VIF::Unit *unit) {
	printf("normal (no mask):\n");
	testMode(unit, VIF::MODE_NORMAL, false);
	
	printf("normal (mask diagonal):\n");
	testMode(unit, VIF::MODE_NORMAL, true, 0x40100401);
	
	printf("offset (no mask):\n");
	testMode(unit, VIF::MODE_OFFSET, false);
	
	printf("offset (mask diagonal):\n");
	testMode(unit, VIF::MODE_OFFSET, true, 0x40100401);
	
	printf("difference (no mask):\n");
	testMode(unit, VIF::MODE_DIFFERENCE, false);
	
	printf("difference (mask diagonal):\n");
	testMode(unit, VIF::MODE_DIFFERENCE, true, 0x40100401);
	
	printf("mode 3 (no mask):\n");
	testMode(unit, 3, false);
	
	printf("mode 3 (mask diagonal):\n");
	testMode(unit, 3, true, 0x40100401);
}
void Settings::writeAuthFile() {
    QVariantMap map;
    QString pre = testMode() ? ST_TEST : ST_PRODUCTION;
    pre += "/";

    map[pre + ST_WORKING_DC_NUM] = m_workingDcNum;
    map[pre + ST_OUR_ID] = m_ourId;

    pre += ST_DCS_ARRAY;
    pre += "/";

    map[pre + "size"] = m_dcsList.length();
    for (qint32 i = 0; i < m_dcsList.length(); i++) {
        QString ar = pre + QString::number(i) + "/";

        map[ar + ST_DC_NUM] = m_dcsList[i]->id();
        map[ar + ST_HOST] = m_dcsList[i]->host();
        map[ar + ST_PORT] = m_dcsList[i]->port();
        map[ar + ST_IPV6] = m_dcsList[i]->ipv6();
        map[ar + ST_MEDIA] = m_dcsList[i]->mediaOnly();
        map[ar + ST_DC_STATE] = m_dcsList[i]->state();

        if (m_dcsList[i]->authKeyId()) {
            map[ar + ST_AUTH_KEY_ID] = m_dcsList[i]->authKeyId();
            QByteArray baToSave(m_dcsList[i]->authKey(), SHARED_KEY_LENGTH);
            map[ar + ST_AUTH_KEY] = baToSave.toBase64();
        }
        map[ar + ST_SERVER_SALT] = m_dcsList[i]->serverSalt();
        map[ar + ST_EXPIRES] = m_dcsList[i]->expires();
    }

    if(!_telegram_settings_write_fnc(mTelegram, map))
        telegram_settings_write_fnc(mTelegram, map);
}
int main(void) {

#ifdef DEBUG_TEST_LOOP
   testMode();
#endif
   init();
   commandLoop();
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    aboutAct = new QAction("A&bout", this);
    aboutQtAct = new QAction("About Q&t", this);
    ui->menuBar->addAction(aboutAct);
    ui->menuBar->addAction(aboutQtAct);
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
    connect(aboutQtAct, SIGNAL(triggered()), QApplication::instance(), SLOT(aboutQt()));


    QRegExpValidator *numberValidator =
               new QRegExpValidator(QRegExp("\\d{2,10}"), this);
    ui->numberEdit->setValidator(numberValidator);

    connect(ui->playerGuessesRadioButton, SIGNAL(clicked(bool)),
            this, SLOT(playerMode()));

    connect(ui->pcGuessesRadioButton, SIGNAL(clicked(bool)),
            this, SLOT(pcMode()));

    connect(ui->testCheckBox, SIGNAL(clicked(bool)),
            this, SLOT(testMode(bool)));

    connect(ui->OKButton, SIGNAL(clicked(bool)),
            this, SLOT(play()));

    connect(ui->generateButton, SIGNAL(clicked(bool)),
            this, SLOT(generateSecret()));

    connect(ui->numberEdit, SIGNAL(textChanged(QString)),
            this, SLOT(checkNumbersLength(QString)));

    connect(ui->numberEdit, SIGNAL(returnPressed()),
            this, SLOT(numberEditReturnPressed()));

    connect(ui->lengthSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(updateMaxLength(int)));

    connect(&bnc, SIGNAL(newOutput(const QStringList &)),
            this, SLOT(updateResultsBrowser(const QStringList &)));

    testMode(false);

    playerMode();
}
Exemple #5
0
bool Adapter::toggleFullScreen(uint nWidth, uint nHeight, uint nColorDepth, uint nFrequency)
{
	DEVMODE DevMode;
	DEVMODE RecDevMode;
	uint nIndex = 0;
	RecDevMode.dmDisplayFrequency	= 0;
	bool bHaveOne	= false;

	//win9x下,取到的刷新率是0 - yun
	DWORD dwStandard = (m_OldDevMode.dmDisplayFrequency > 0 ? m_OldDevMode.dmDisplayFrequency : nFrequency);

	//Trace("OriginFreq = %d\n",m_OldDevMode.dmDisplayFrequency);

	while( EnumDisplaySettings(NULL,nIndex,&DevMode)!=0 )
	{
		if(DevMode.dmPelsWidth == (DWORD)nWidth && DevMode.dmPelsHeight == (DWORD)nHeight && DevMode.dmBitsPerPel == (DWORD)nColorDepth)
		{
			//Trace("%d*%d*%d %d\n",DevMode.dmPelsWidth,DevMode.dmPelsHeight,DevMode.dmBitsPerPel,DevMode.dmDisplayFrequency);
			if(DevMode.dmDisplayFrequency <= dwStandard)
			{
				if(testMode(DevMode))
				{
					//Trace("TestMode Ok! %d*%d*%d %d\n",DevMode.dmPelsWidth,DevMode.dmPelsHeight,DevMode.dmBitsPerPel,DevMode.dmDisplayFrequency);
					if(DevMode.dmDisplayFrequency >= RecDevMode.dmDisplayFrequency)
					{
						memcpy(&RecDevMode,&DevMode,sizeof(DEVMODE));
						bHaveOne	= true;
					}
				}
			}
		}
		nIndex++;
	}

	bool bRet = FALSE;
	if(bHaveOne)
	{
		if(RecDevMode.dmDisplayFrequency == 0)
			RecDevMode.dmDisplayFrequency = nFrequency;

		bRet = fullScreen(RecDevMode);

		//Trace("DEVMODE = %d*%d*%d %d",DevMode.dmPelsWidth,DevMode.dmPelsHeight,DevMode.dmBitsPerPel,DevMode.dmDisplayFrequency);
	}

	return bRet;
}
void Settings::readAuthFile() {
    QVariantMap map;
    if(!_telegram_settings_read_fnc(mTelegram, map))
        telegram_settings_read_fnc(mTelegram, map);

    QString pre = testMode() ? ST_TEST : ST_PRODUCTION;
    pre += "/";

    qint32 defaultDcId = m_testMode ? TEST_DEFAULT_DC_ID : Settings::defaultHostDcId();

    m_workingDcNum = map.value(pre+ST_WORKING_DC_NUM, defaultDcId).toInt();
    m_ourId = map.value(pre+ST_OUR_ID).toInt();
    m_workingDcConfigAvailabe = map.contains(pre+ST_WORKING_DC_NUM);
    qCDebug(TG_CORE_SETTINGS) << "workingDcNum:" << m_workingDcNum;
    qCDebug(TG_CORE_SETTINGS) << "ourId:" << m_ourId;

    pre += ST_DCS_ARRAY;
    pre += "/";

    qint32 n = map.value(pre + "size").toInt();
    for (qint32 i = 0; i < n; i++) {
        QString ar = pre + QString::number(i) + "/";

        qint32 dcNum = map.value(ar+ST_DC_NUM).toInt();
        DC* dc = new DC(dcNum);
        dc->setHost(map.value(ar+ST_HOST).toString());
        dc->setPort(map.value(ar+ST_PORT, 0).toInt());
        dc->setIpv6(map.value(ar+ST_IPV6).toBool());
        dc->setMediaOnly(map.value(ar+ST_MEDIA).toBool());
        dc->setState((DC::DcState)map.value(ar+ST_DC_STATE, DC::init).toInt());
        dc->setAuthKeyId(map.value(ar+ST_AUTH_KEY_ID, 0).toLongLong());
        if (dc->state() >= DC::authKeyCreated) {
            QByteArray readedBa = QByteArray::fromBase64(map.value(ar+ST_AUTH_KEY).toByteArray());
            memcpy(dc->authKey(), readedBa.data(), SHARED_KEY_LENGTH);
        }
        dc->setServerSalt(map.value(ar+ST_SERVER_SALT, 0).toLongLong());
        dc->setExpires(map.value(ar+ST_EXPIRES).toInt());

        qCDebug(TG_CORE_SETTINGS) << "DC | id:" << dc->id() << ", state:" << dc->state() <<
                    ", host:" << dc->host() << ", port:" << dc->port() <<
                    ", expires:" << dc->expires() << ", authKeyId:" << dc->authKeyId() <<
                    ", serverSalt:" << dc->serverSalt() << ", ipv6" << dc->ipv6();

        m_dcsList.insert(dcNum, dc);
    }
}
Exemple #7
0
/**
 *  Handles switching between modes.
 * */
void loop()
{   
    switch (mode) {
        case METERMODE:
            meterMode();
            break;
        case INTERACTIVEMODE:
            parseBerkeley();
            break;
        case TESTMODE:
            testMode();
            break;
        default:
            dbg.println("Invalid Mode setting to interactive mode");
            mode = INTERACTIVEMODE;
            break;
    }
}
Exemple #8
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Menu
    QMenu* modelMenu = menuBar()->addMenu("&Model");
    modelMenu->addAction("&Open model...",  this, SLOT(openModel()) );
    modelMenu->addSeparator();
    modelMenu->addAction("&Close model",    this, SLOT(closeModel()) );

    QMenu* markMenu = menuBar()->addMenu("&Bookmarks");
    markMenu->addAction("&New file...",     this, SLOT(closeBookmarksFile()) );
    markMenu->addAction("&Open file...",    this, SLOT(openBookmarksFile()) );
    markMenu->addSeparator();
    markMenu->addAction("&Close file",      this, SLOT(closeBookmarksFile()) );
    markMenu->addSeparator();
    markMenu->addAction("&Save file", this, SLOT(saveBookmarksFile()));
    markMenu->addAction("&Save file as...", this, SLOT(saveAsBookmarksFile()));

    QMenu* viewMenu = menuBar()->addMenu("&View");
    viewMenu->addAction("&View as points",    this,       SLOT(viewAsPoints()) );
    viewMenu->addAction("&View as wired",    this,       SLOT(viewAsWired()) );
    viewMenu->addAction("&View as solid",  this,        SLOT(viewAsSolid()) );
    viewMenu->addAction("&View as solid + wired",this,   SLOT(viewAsSolidWire()) );

    QMenu* modeMenu = menuBar()->addMenu("&Mode");
    modeMenu->addAction("&Viewer",    this,             SLOT(viewerMode()) );
    modeMenu->addAction("&Editor",    this,             SLOT(editorMode()) );
    modeMenu->addAction("&Ask Me!",      this,             SLOT(testMode()) );


    // Section list panel buttons.
    QObject::connect(ui->addButton, SIGNAL(clicked()), this, SLOT(showAddSectionPanel()));
    QObject::connect(ui->editButton, SIGNAL(clicked()), this, SLOT(showEditSectionPanel()));
    QObject::connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteCurrentSection()));
    QObject::connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(showInfoSectionPanel()));
    QObject::connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
                     this, SLOT(listWidgetItemClicked(QListWidgetItem*)));

    // Add bookmark panel buttons.
    QObject::connect(ui->addModeButton, SIGNAL(clicked()), this, SLOT(setAddSelectionMode()));
    QObject::connect(ui->removeModeButton, SIGNAL(clicked()), this, SLOT(setRemoveSelectionMode()));
    QObject::connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveBookmark()));
    QObject::connect(ui->discardButton, SIGNAL(clicked()), this, SLOT(discardBookmark()));
    QObject::connect(ui->brushSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrushSize(int)));

    // Information panel buttons
    QObject::connect(ui->backButton, SIGNAL(clicked()), this, SLOT(showListPanel()));

    // Test panel buttons
    QObject::connect(ui->nextQuestionButton, SIGNAL(clicked()), this, SLOT(nextQuestion()));
    QObject::connect(ui->glwidget, SIGNAL(pickResult(std::set<unsigned int>)), this, SLOT(checkResponse(std::set<unsigned int>)));


    // Set window title.
    setWindowTitle("untitled.txt");

    // Initialize variables.
    _bookmarkList = new BookmarkList();
    clearBookmarkList();
    _model = new Model();
    _indexTest = 0;

    // Set viewer mode.
    viewerMode();

    // Show welcome message
    statusBar()->showMessage("Welcome to 3D Marker.");
}