Exemplo n.º 1
0
void SidebarWindow::refresh(bool loggedin) {
    //LOG4CPLUS_DEBUG(LogUtils::getLogger(),
//   "SidebarWindow::refresh current state = " <<
//   friendsView_->getViewState() <<
//   ", new state = " << loggedin <<
//   ", is currently visible = " << RuntimeContext::isSidebarOpened());
    switch (friendsView_->getViewState()) {
    case SidebarHtmlView::VS_LOADING_FRIENDS:
        break;
    case SidebarHtmlView::VS_INITIAL:
    case SidebarHtmlView::VS_WAIT_LOGIN: {
        if (loggedin) {
            loading();
            UserDataObserver::getInstance().getFriends();
        } else {
            loggedOut();
        }
        break;
    }
    case SidebarHtmlView::VS_FRIENDS_LOADED: {
        if (!loggedin) {
            loggedOut();
        }
        break;
    }
    }
}
Exemplo n.º 2
0
void IEToolbar::createToolbarWindow() {
  toolbarWindow_.create(siteWindow_);

  // Load and assign images for toolbar's buttons.
  setupToolbarImages();
  setupToolbarHotImages();

  // Create all toolbar elements.
  createToolbarItems();

  // Store toolbar reference for 
  RuntimeContext::storeToolbar(*this);

  // subscribe for https responces tracking
  CComPtr<IInternetSession> session;
  CoInternetGetSession(0, &session, 0);
  SessionMetaFactory::CreateInstance(CLSID_HttpSProtocol, 
    &httpsFactory_, siteWindow_.m_hWnd);
  session->RegisterNameSpace(httpsFactory_, CLSID_NULL, L"https", 0, 0, 0);

  // subscribe for http responces tracking
  SessionMetaFactory::CreateInstance(CLSID_HttpProtocol, 
    &httpFactory_, siteWindow_.m_hWnd);
  session->RegisterNameSpace(httpFactory_, CLSID_NULL, L"http", 0, 0, 0);

  // Switch toolbar to appropriate state.
  if (UserDataObserver::getInstance().isLoggedIn()) {
    loggedIn();
  } else {
    loggedOut();
  }
}
Exemplo n.º 3
0
void IEToolbar::dataUpdated(unsigned long dataId) {
  UserDataObserver& dataObserver = UserDataObserver::getInstance();

  //LOG4CPLUS_DEBUG(LogUtils::getLogger(), "IEToolbar::dataUpdated dataId = " << dataId);
  switch (dataId) {
  case FBM_POKES_COUNT_UPDATED:
    return setPokesCount(dataObserver.getPokesCount(false));
  case FBM_MESSAGES_CONT_UPDATED:
    return setMessagesCount(dataObserver.getMessagesCount(false));
  case FBM_REQUESTS_COUNT_PDATED:
    return setRequestsCount(dataObserver.getRequestsCount(false));
  case FBM_EVENTS_INVINTAIONS_COUNT_UPDATED:
    return setEventInvsCount(dataObserver.getEventsCount(false));
  case FBM_GROUPS_INVINTAIONS_COUNT_UPDATED:
    return setGroupInvsCount(dataObserver.getGroupsInvsCount(false));
  case FBM_MY_STATUS_UPDATED:
    setProfileName(dataObserver.getLoggedInUser(false).getName());
    setStatusText(dataObserver.getLoggedInUser(false).getStatusMessage());
    return;
  case FBM_JUST_LOGGED_IN:
    return loggedIn();
  case FBM_LOGOUT_INITIATED:
    return loggedOut();
  case FBM_UPDATE_VIEW:
    //updateView();
    break;
  }
}
Exemplo n.º 4
0
MrimAccount::MrimAccount(const QString& email)
        : Account(email,MrimProtocol::instance()), p(new MrimAccountPrivate(this))
{   
    connect(connection(),SIGNAL(loggedOut()),
            roster(),SLOT(handleLoggedOut()),Qt::QueuedConnection);
    p->conn->registerPacketHandler(p->roster.data());
//    p->conn->start(); //TODO: temporary autologin, for debugging
}
Exemplo n.º 5
0
void GaduProtocol::logout()
{
    // we need to changestatus manually in gadu
    // status is offline
    sendStatusToServer();
    // Kadu bug #2542
    // gg_logoff(GaduSession);

    // TODO: it never gets called when unloading gadu_protocol and causes memory and resource leak
    QTimer::singleShot(0, this, SLOT(loggedOut()));
}
Exemplo n.º 6
0
void rpc::account_create(const std::string& user, const std::string& inputPass)
{
    session().load();

    if (loggedOut() && !user.empty() && !inputPass.empty())
    {
        User u(user, inputPass);
        std::string hash = genPass(inputPass);

        if (u.valid() && db.addUser(user, hash) > 0 && login(user, inputPass))
        {
            return_result(true);
            return;
        }
    }

    return_result(false);
}
Exemplo n.º 7
0
void MrimConnection::disconnected()
{
    QTcpSocket *socket = qobject_cast<QTcpSocket*>(sender());
    Q_ASSERT(socket);

    debug()<<"Disconnected from server"<<qPrintable( Utils::toHostPortPair(socket->peerAddress(),socket->peerPort()) );

    if (socket == p->SrvReqSocket())
    {
        if (!p->imHost.isEmpty() && p->imPort > 0)
        {//all is fine, connecting to IM server
            p->IMSocket()->connectToHost(p->imHost,p->imPort);
        }
        else
        {
            critical()<<"Oh god! This is epic fail! We didn't recieve any server, so connection couldn't be established!";
        }
    } else emit loggedOut();
}
Exemplo n.º 8
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    t = new QtTelnet;

    connect(t, SIGNAL(message(const QString &)),
                   this, SLOT(telnetMessage(const QString &)));
    connect(t, SIGNAL(loginRequired()),
                    this, SLOT(telnetLoginRequired()));
    connect(t, SIGNAL(loginFailed()),
                    this, SLOT(telnetLoginFailed()));
    connect(t, SIGNAL(loggedOut()),
                   this, SLOT(telnetLoggedOut()));
    connect(t, SIGNAL(loggedIn()),
                   this, SLOT(telnetLoggedIn()));
    connect(t, SIGNAL(connectionError(QAbstractSocket::SocketError)),
                    this, SLOT(telnetConnectionError(QAbstractSocket::SocketError)));

}
Exemplo n.º 9
0
	TrayIcon::TrayIcon(MainWindow* parent)
		: QObject(parent)
		, MainWindow_(parent)
		, Icon_(new QSystemTrayIcon(this))
		, Menu_(new ContextMenu(0))
		, MessageAlert_(new RecentMessagesAlert(new Logic::RecentItemDelegate(this)))
		, Base_(new QIcon(":/resources/main_window/appicon.ico"))
		, Unreads_(new QIcon(":/resources/main_window/appicon_unread.ico"))
#ifdef _WIN32
		, TrayBase_(new QIcon(":/resources/main_window/appicon_tray.ico"))
        , TrayUnreads_(new QIcon(":/resources/main_window/appicon_tray_unread.ico"))
#else
        , TrayBase_(new QIcon(":/resources/main_window/appicon.ico"))
        , TrayUnreads_(new QIcon(":/resources/main_window/appicon_unread.ico"))
#endif //_WIN32
        , TaskBarOverlay_(new QPixmap(":/resources/main_window/appicon_overlay.png"))
		, HaveUnreads_(false)
#ifdef _WIN32
        , ptbl(0)
#endif //_WIN32
	{
#ifdef _WIN32
        if (QSysInfo().windowsVersion() >= QSysInfo::WV_WINDOWS7)
        {
            HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ptbl));
            if (FAILED(hr))
                ptbl = 0;
        }
#endif //_WIN32
		init();
        
        connect(Ui::GetDispatcher(), SIGNAL(login_complete()), this, SLOT(loggedIn()), Qt::QueuedConnection);
		connect(MessageAlert_, SIGNAL(messageClicked(QString)), this, SLOT(messageClicked(QString)), Qt::QueuedConnection);
		connect(Logic::GetContactListModel(), SIGNAL(selectedContactChanged(QString)), this, SLOT(clearNotifications(QString)), Qt::QueuedConnection);
		connect(Logic::GetContactListModel(), SIGNAL(contactChanged(QString)), this, SLOT(updateIcon()), Qt::QueuedConnection);
        connect(Ui::GetDispatcher(), SIGNAL(myInfo()), this, SLOT(myInfo()));
        connect(Ui::GetDispatcher(), SIGNAL(needLogin()), this, SLOT(loggedOut()), Qt::QueuedConnection);
	}
Exemplo n.º 10
0
LoginDialog::LoginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginDialog),
    spotify(new Spotify),
    useCredentialBlob(false)
{
    ui->setupUi(this);
    QStringList usernames = settings.value("spotify/usernames").toStringList();
    if (!usernames.isEmpty()) {
        ui->usernameComboBox->addItems(usernames);
    }
    QString user = settings.value("spotify/last_user").toString();
    ui->usernameComboBox->setCurrentText(user);
    userChanged(user);
    connect(ui->usernameComboBox, SIGNAL(currentIndexChanged(QString)),
            this, SLOT(userChanged(QString)));
    connect(ui->passwordLineEdit, SIGNAL(textEdited(QString)), this, SLOT(resetBlobUse()));

    bool dm = settings.value("login/dungeon_master").toBool();
    if (dm) {
        ui->dmCheckBox->setCheckState(Qt::Checked);
    }
    else {
        ui->dmCheckBox->setCheckState(Qt::Unchecked);
    }

    QString room = settings.value("login/room").toString();
    ui->roomLineEdit->setText(room);

    connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(acceptLogin()));
    connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    connect(spotify, SIGNAL(loggedIn()), this, SLOT(accept()));
    connect(spotify, SIGNAL(loggedOut()), this, SLOT(spotifyLoggedOut()));
    connect(this, SIGNAL(tryLogin(QString)), spotify, SLOT(login(QString)));
    connect(this, SIGNAL(tryLogin(QString,QString)), spotify, SLOT(login(QString,QString)));
    spotify->start();
}
Exemplo n.º 11
0
LRESULT SidebarWindow::onDataChanged(WPARAM wParam, LPARAM) {
    bool visible = RuntimeContext::isSidebarOpened() || isVisible_;
    //do *not* process data updates if sidebar is closed
    switch(wParam) {
    case FBM_LOADING_DATA:
        break;
    case FBM_JUST_LOGGED_IN:
    case FBM_MY_FRIENDS_LIST_UPDATED:
        if (visible) {
            loaded(
                UserDataObserver::getInstance().getFriends(false));
        }
        break;
    case FBM_LOGOUT_INITIATED:
        loggedOut();
        break;
    case FBM_UPDATE_VIEW:
        updateView();
        break;
    }

    return visible ? TRUE : FALSE;
}
Exemplo n.º 12
0
int logOut(LtpInterfaceType *ltpInterfaceP,Boolean clearAllB)
{
	if(ltpInterfaceP)
	{	
		ltpInterfaceP->checkPortAgainB = 1;
		if(ltpInterfaceP->pjsipThreadStartB==false || ltpInterfaceP->ltpObjectP->sipOnB==false)
		{	
			ltpLogin(ltpInterfaceP->ltpObjectP,CMD_LOGOUT);
			
		}	
		else {
			ltpInterfaceP->LogoutSendB = 1;
		}

		if(clearAllB)
		{	sip_destroy_transation(ltpInterfaceP->ltpObjectP);
			loggedOut();
			profileClear();
			cdrRemoveAll();
			resetMissCallCount();
			setLtpUserName(ltpInterfaceP,"");
			setLtpPassword(ltpInterfaceP,"");
			ltpInterfaceP->firstTimeLoginB = true;
		}
		else
		{
			if(ltpInterfaceP->ltpObjectP)
			{	
				if (ltpInterfaceP->ltpObjectP->ltpUserid[0])
					profileSave();
			}	
		}
		return 0;
	}	
	return 1;
	
}
Exemplo n.º 13
0
SpotFmApp::SpotFmApp(int &argc, char **argv) throw(SpotFmException)
    : QApplication(argc, argv)
    , m_mainWindow(0)
{
    m_settings = new QSettings(
                QSettings::IniFormat,
				QSettings::UserScope,
				QCoreApplication::organizationName(),
				QCoreApplication::applicationName());

	//Initalizate the spotify session
    SpotifySession *spSession = new SpotifySession();

    m_logoutAndQuit = false;

    LoginDialog d(m_settings->value("Username").toString());
    if (!m_settings->value("Username").toString().isEmpty() &&
            !m_settings->value("Password").toString().isEmpty()) {
        d.setPassword(m_settings->value("Password").toString());
        d.authenticate();
    }
    if (d.exec() != QDialog::Accepted) {
        throw SpotFmException();
    }
    if (d.save() &&
        (m_settings->value("Username").toString() != d.username() ||
        m_settings->value("Password").toString() != d.password())) {
        m_settings->setValue("Username", d.username());
        m_settings->setValue("Password", d.password());
    }
    connect(spSession, SIGNAL(loggedOut()), this, SLOT(onLoggedOut()));

    m_radio = new Radio();

    m_mainWindow = new MainWindow();
    m_mainWindow->show();
}
Exemplo n.º 14
0
void Spotify::run()
{
    int next_timeout = 0;

    sp = spotify_ll_init(Spotify_Wrapper::sessionCallbacks());
    if (!sp) {
        return;
    }

    bool running = true;
    while (running) {
        SpotifyEvent_t ev = EVENT_NO_EVENT;
        // Get next event (or timeout)
        if (next_timeout == 0) {
            eq.get(ev);
        } else {
            if (!eq.get(ev, next_timeout)) {
                // Timed out
                ev = EVENT_TIMEOUT;
            }
        }

        switch (ev) {
        case EVENT_SPOTIFY_MAIN_TICK:
        case EVENT_TIMEOUT:
            break;

        case EVENT_LOGIN_CREDENTIALS_CHANGED:
            if (pass.isEmpty()) {
                // Try using credential blob
                sp_session_login(sp,
                                 user.toLocal8Bit().constData(),
                                 NULL,
                                 false,
                                 blob.constData());
            }
            else {
                sp_session_login(sp,
                                 user.toLocal8Bit().constData(),
                                 pass.toLocal8Bit().constData(),
                                 false,
                                 NULL);
            }
            break;

        case EVENT_LOGGED_IN:
            emit loggedIn();
            break;

        case EVENT_PLAYLIST_CONTAINER_LOADED:
            compileNewListOfPlaylists();
            break;

        case EVENT_LOGGED_OUT:
            emit loggedOut();
            break;

        case EVENT_URI_CHANGED:
            changeCurrentlyPlayingSong();
            break;

        case EVENT_PLAYLIST_IDX_CHANGED:
            changeCurrentPlaylist();
            break;

        case EVENT_METADATA_UPDATED:
            tryLoadTrack();
            break;

        case EVENT_START_PLAYBACK:
            if (!audioThread.isRunning()) {
                fprintf(stderr, "Spotify: Starting audio worker\n");

                SpotifyAudioWorker * audioWorker = new SpotifyAudioWorker(this);
                audioWorker->moveToThread(&audioThread);
                connect(&audioThread, SIGNAL(started()),
                        audioWorker, SLOT(startStreaming()));
                connect(&audioThread, SIGNAL(finished()),
                        audioWorker, SLOT(stopStreaming()));
                connect(&audioThread, SIGNAL(finished()),
                        audioWorker, SLOT(deleteLater()));
                connect(audioWorker, SIGNAL(streamingFailed()),
                        this, SIGNAL(audioStreamingFailed()));
                audioThread.start();
            }
            break;

        case EVENT_STOP_PLAYBACK:
            if (audioThread.isRunning()) {
                audioThread.quit();
                audioThread.wait();
            }
            accessMutex.lock();
            audioBuffer.close();
            readPos = 0;
            writePos = 0;
            accessMutex.unlock();
            break;

        case EVENT_END_OF_TRACK:
            sp_session_player_unload(sp);
            sp_track_release(currentTrack);
            currentURI.clear();
            nextTrack = 0;
            currentTrack = 0;
            break;

        default:
            qDebug() << "Unknown event:" << (int)ev;
            break;
        }

        do {
            sp_session_process_events(sp, &next_timeout);
        } while (next_timeout == 0);
    }
}
Exemplo n.º 15
0
void SpotWorker::emitLoggedOutSignal(sp_session *session)
{
    DEBUG printf("Emitting signal loggedOut\n");
    emit loggedOut(session);
}