dialogOauthSetup::dialogOauthSetup(QWidget *parent) : QDialog(parent), ui(new Ui::dialogOauthSetup) { ui->setupUi(this); profileimageUrl = ""; if (genericHelper::getOAuthAccessToken().length() > 3) { tw = new TwitchApi(this, genericHelper::getOAuthAccessToken()); } else { tw = new TwitchApi(this, ""); } // init the image loader imgl = new imageLoader(this); QObject::connect(tw, SIGNAL(twitchReady(const QJsonDocument)), this, SLOT(on_AuthSuccess(const QJsonDocument))); QObject::connect(tw, SIGNAL(networkError(QString)), this, SLOT(errorPopup(QString))); QObject::connect(imgl, SIGNAL(downloaded()), this, SLOT(loadProfileImage())); }
void CoreConnection::connectToCurrentAccount() { if (_authHandler) { qWarning() << Q_FUNC_INFO << "Already connected!"; return; } resetConnection(false); if (currentAccount().isInternal()) { if (Quassel::runMode() != Quassel::Monolithic) { qWarning() << "Cannot connect to internal core in client-only mode!"; return; } emit startInternalCore(); InternalPeer *peer = new InternalPeer(); _peer = peer; Client::instance()->signalProxy()->addPeer(peer); // sigproxy will take ownership emit connectToInternalCore(peer); setState(Connected); return; } _authHandler = new ClientAuthHandler(currentAccount(), this); connect(_authHandler, SIGNAL(disconnected()), SLOT(coreSocketDisconnected())); connect(_authHandler, SIGNAL(connectionReady()), SLOT(onConnectionReady())); connect(_authHandler, SIGNAL(socketError(QAbstractSocket::SocketError,QString)), SLOT(coreSocketError(QAbstractSocket::SocketError,QString))); connect(_authHandler, SIGNAL(transferProgress(int,int)), SLOT(updateProgress(int,int))); connect(_authHandler, SIGNAL(requestDisconnect(QString,bool)), SLOT(disconnectFromCore(QString,bool))); connect(_authHandler, SIGNAL(errorMessage(QString)), SIGNAL(connectionError(QString))); connect(_authHandler, SIGNAL(errorPopup(QString)), SIGNAL(connectionErrorPopup(QString)), Qt::QueuedConnection); connect(_authHandler, SIGNAL(statusMessage(QString)), SIGNAL(connectionMsg(QString))); connect(_authHandler, SIGNAL(encrypted(bool)), SIGNAL(encrypted(bool))); connect(_authHandler, SIGNAL(startCoreSetup(QVariantList)), SIGNAL(startCoreSetup(QVariantList))); connect(_authHandler, SIGNAL(coreSetupFailed(QString)), SIGNAL(coreSetupFailed(QString))); connect(_authHandler, SIGNAL(coreSetupSuccessful()), SIGNAL(coreSetupSuccess())); connect(_authHandler, SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString)), SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString))); connect(_authHandler, SIGNAL(handleNoSslInClient(bool*)), SIGNAL(handleNoSslInClient(bool*))); connect(_authHandler, SIGNAL(handleNoSslInCore(bool*)), SIGNAL(handleNoSslInCore(bool*))); #ifdef HAVE_SSL connect(_authHandler, SIGNAL(handleSslErrors(const QSslSocket*,bool*,bool*)), SIGNAL(handleSslErrors(const QSslSocket*,bool*,bool*))); #endif connect(_authHandler, SIGNAL(loginSuccessful(CoreAccount)), SLOT(onLoginSuccessful(CoreAccount))); connect(_authHandler, SIGNAL(handshakeComplete(RemotePeer*,Protocol::SessionState)), SLOT(onHandshakeComplete(RemotePeer*,Protocol::SessionState))); setState(Connecting); _authHandler->connectToCore(); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow) { if (initialize()) { run(); } else { errorPopup("Initialization failed!"); return 0; } shutdown(); return 0; }
bool initialize() { // Create components renderer = new Renderer(); ai = new AI(); input = new Input(); sound = new Sound(); quit = false; prevTime = 0; // TO DO: Load config.ini file to set up resolution and input settings // Set up the window (refernced a tutorial at http://www.rastertek.com/dx10tut02.html) WNDCLASSEX wc; DEVMODE screenSettings; // Get initial screen settings initialScreenSettings.dmSize = sizeof(DEVMODE); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &initialScreenSettings); // Initialize screenSettings screenSettings.dmSize = sizeof(DEVMODE); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &screenSettings); hInstance = GetModuleHandle(NULL); appName = "Via Invictus"; memset(&wc, 0, sizeof(WNDCLASSEX)); wc.style = CS_HREDRAW | CS_VREDRAW;// | CS_OWNDC; wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hIconSm = wc.hIcon; wc.hCursor = LoadCursor(NULL, IDC_ARROW); //wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszClassName = appName; wc.cbSize = sizeof(WNDCLASSEX); // Register the window class. RegisterClassEx(&wc); unsigned long resx, resy; // Get screen resolution resx = initialScreenSettings.dmPelsWidth; resy = initialScreenSettings.dmPelsHeight; screenSettings.dmPelsWidth = resx; // Screen width screenSettings.dmPelsHeight = resy; // Screen height screenSettings.dmBitsPerPel = initialScreenSettings.dmBitsPerPel; // bit depth screenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if (ChangeDisplaySettings(&screenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { errorPopup("Changing display settings failed!"); return false; } // Create the window at position 0, 0, and with the resolution defined just above hwnd = CreateWindowEx(WS_EX_APPWINDOW, appName, appName, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP, 0, 0, resx, resy, NULL, NULL, hInstance, NULL); // Bring up the window and set focus ShowWindow(hwnd, SW_SHOWNORMAL); SetForegroundWindow(hwnd); SetFocus(hwnd); // Capture the mouse SetCapture(hwnd); // Keep the mouse in the application area (maybe not necessary since we're doing fullscreen) RECT rect; GetWindowRect(hwnd, &rect); ClipCursor(&rect); // Hide the mouse ShowCursor(false); // Initialize components if (!renderer || !ai || !sound || !input) { errorPopup("Creating Renderer, AI, Sound, or Input component failed! [!renderer || !ai || !sound || !input]"); return false; } // TO DO: Run the 'initialize' method for each component char* errorMsg = new char[128]; if (!(renderer->initialize(resx, resy, hwnd, 1.0f, 1200.0f, 200, errorMsg))) { errorPopup(errorMsg); errorPopup("Renderer initialization failed!"); return false; } ai->initialize(renderer, input, sound); if (!sound->initialized) { errorPopup("Sound initialization failed!"); return false; } // We want to capture raw keyboard and mouse data, and ignore normal // window handler keyboard/mouse messages RAWINPUTDEVICE rawInpDev[2]; rawInpDev[0].usUsagePage = 1; rawInpDev[0].usUsage = 2; // MOUSE rawInpDev[0].dwFlags = RIDEV_NOLEGACY; rawInpDev[0].hwndTarget = NULL; rawInpDev[1].usUsagePage = 1; rawInpDev[1].usUsage = 6; // KEYBOARD rawInpDev[1].dwFlags = RIDEV_NOLEGACY; rawInpDev[1].hwndTarget = NULL; if (!RegisterRawInputDevices(rawInpDev, 2, sizeof(RAWINPUTDEVICE))) { errorPopup("Failed to capture keyboard and mouse input!"); return false; } return true; }