예제 #1
0
파일: systray.cpp 프로젝트: jplsek/puush-qt
/**
 * Puush upload the clipboard
 * @brief Systray::uploadClipboard
 */
void Systray::uploadClipboard()
{
    if (!isLoggedIn())
        return;

    QString text = QApplication::clipboard()->text();

    // just look for "file://" and upload it, else just upload the text itself as a text file
    if (text.isEmpty()) {
        return;
    } else if (text.contains("file://")) {
        Upload *u = new Upload(text);

        connect(u, SIGNAL(started()), this, SLOT(puushStarted()));
        connect(u, SIGNAL(finished(QString)), this, SLOT(puushDone(QString)));
    } else {
        QTemporaryFile file;
        // The file is deleted too soon before it can be uploaded since the upload is in a callback.
        // Since it's in a temporary directory it'll get deleted eventually anyways...
        file.setAutoRemove(false);

        if (file.open()) {
            file.write(text.toLocal8Bit().data());

            Upload *u = new Upload(file.fileName());

            connect(u, SIGNAL(started()), this, SLOT(puushStarted()));
            connect(u, SIGNAL(finished(QString)), this, SLOT(puushDone(QString)));
        } else {
            trayIcon->showMessage("puush-qt", tr("Error opening temporary file for writing!"),
                                  QSystemTrayIcon::Critical);
        }
    }
}
예제 #2
0
void Player::showTeamChange(bool n)
{
    if (!isLoggedIn())
        return; //INV BEHAV
    showteam() = n;
    emit updated(id());
}
예제 #3
0
void OKSocialPluginAndroid::getMyProfile(int preferedPictureSize, void *userData, const std::vector<std::string> &additionalFields)
{
    if (!isLoggedIn())
    {
        if (_delegate)
            _delegate->onGetMyProfile({SocialPluginDelegate::Error::Type::NO_LOGIN, 0, ""}, userData, _emptyProfile);
        return;
    }

    std::string fields = "uid,first_name,last_name,email,birthday,gender";
    for (const auto &field : additionalFields)
        fields += "," + field;

    auto picturesMapIterator = _picturesMap.lower_bound(preferedPictureSize);
    const auto &pictureField = (picturesMapIterator == _picturesMap.end()) ? _picturesMap.rbegin()->second : picturesMapIterator->second;
    fields += "," + _pictureIDKey + "," + pictureField;

    cocos2d::JniMethodInfo methodInfo;
    if (cocos2d::JniHelper::getStaticMethodInfo(methodInfo, HELPER_CLASS_NAME, "getMyProfile", "(Ljava/lang/String;JLjava/lang/String;Z)V"))
    {
        jstring jFields = methodInfo.env->NewStringUTF(fields.c_str());
        jstring jPictureField = methodInfo.env->NewStringUTF(pictureField.c_str());
        methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, jFields, (jlong)userData, jPictureField, (jboolean)_debug);
        methodInfo.env->DeleteLocalRef(methodInfo.classID);
//        methodInfo.env->DeleteLocalRef(jFields); // TODO
//        methodInfo.env->DeleteLocalRef(jPictureField); // TODO
    }
}
예제 #4
0
void Player::ladderChange(bool n)
{
    if (!isLoggedIn())
        return;//INV BEHAV
    ladder() = n;
    emit updated(id());
}
예제 #5
0
void Player::autoKick()
{
    if (!isLoggedIn()) {
        blockSignals(false); // In case we autokick an alt that was already disconnected
        disconnected();
    }
}
예제 #6
0
파일: systray.cpp 프로젝트: jplsek/puush-qt
void Systray::openAccount()
{
    if (!isLoggedIn())
        return;

    QString key = s.value(Settings::ACCOUNT_API_KEY).toString();
    openUrl(QUrl(s.value(Settings::BASE_URL).toString() + "login/go/?k=" + key));
}
예제 #7
0
	void Apply(User* u)
	{
		if (!isLoggedIn(u))
		{
			u->WriteServ("NOTICE %s :*** NOTICE -- You need to identify via SASL to use this server (your host is %s-Lined).", u->nick.c_str(), type.c_str());
			ServerInstance->Users->QuitUser(u, type + "-Lined: "+this->reason);
		}
	}
예제 #8
0
bool recordDatabase::addToRecord(Field field, int valueToAdd){
	if (isLoggedIn()){
		DatabaseEntry *prevValue[MAX_FIELDS];
		bool recordGotten = getRecord({ &field }, 1, prevValue);
		if (recordGotten){
			return updateRecord(field, prevValue[0]->intValue + valueToAdd, false);
		}
	}
	return false;
}
예제 #9
0
void Player::ladderChange(bool n)
{
    if (!isLoggedIn())
        return;//INV BEHAV
    if (state()[LadderEnabled] == n) {
        return;
    }
    state().setFlag(LadderEnabled, n);
    relay().notifyOptionsChange(id(), away(), n);
}
예제 #10
0
파일: VKApi.cpp 프로젝트: JohnPoison/QVKApi
void VKApi::method(const QString &method,
        const QMap<QString, QString> params,
        std::function< void(const QJsonDocument*, QNetworkReply::NetworkError) > callback
)  {
    QUrl url( kApiBaseUrl + method );

    QUrlQuery q;

    if (!params.empty()) {
        for (const auto& key : params) {
            q.addQueryItem( key, params.value(key) );
        }
    }

    if (isLoggedIn())
        q.addQueryItem("access_token", accessToken);
    url.setQuery(q);

    QNetworkRequest req;
    req.setUrl(url);

    qDebug() << "Sending request to: " << req.url().toString() << "\n";
    auto reply = net.get(req);
    connect(reply, &QNetworkReply::finished, [reply, callback]() {
        QJsonDocument* json = 0;
        QJsonDocument jsonDoc;
        QNetworkReply::NetworkError error = reply->error();
        qDebug() << "Finished reply: " << reply << "\n";
        if (reply->error() != QNetworkReply::NetworkError::NoError) {
            qDebug() << "Network error: " << reply->errorString() << "\n";
        } else {
            QJsonParseError parseErr;
            auto data = reply->readAll();
            jsonDoc = QJsonDocument::fromJson(data , &parseErr );

            qDebug() << "got response <" << reply->url() << ">\n" << data << "\n\n\n";

            if (parseErr.error != QJsonParseError::NoError) {
                qDebug() << "failed to parse json: " << parseErr.errorString() << "\n";
                error = QNetworkReply::NetworkError::UnknownContentError;
            } else if (!jsonDoc.object().contains("response")) {
                qDebug() << "bad json.\n";
                error = QNetworkReply::NetworkError::UnknownContentError;
            } else {
                jsonDoc = QJsonDocument( jsonDoc.object().value( "response" ).toArray().at(0).toObject() );
                json = &jsonDoc;
            }
        }

        if (callback)
            callback(json, error);

        reply->deleteLater();
    });
}
예제 #11
0
파일: systray.cpp 프로젝트: jplsek/puush-qt
/**
 * Puush capture area screenshot.
 * @brief Systray::selectAreaScreenshot
 */
void Systray::selectAreaScreenshot()
{
    if (!isLoggedIn())
        return;

    QString fileName = getTempPath();
    Screenshot *ss = new Screenshot(fileName);
    connect(ss, SIGNAL(finished(int, QString, QString)), this, SLOT(screenshotDone(int, QString,
                                                                                   QString)));
    ss->selectArea();
}
예제 #12
0
void IRCServer::sendCommandsInQueue()
{
    if (isLoggedIn())
    {
        while(!commandsInQueue_m.isEmpty())
        {
            QByteArray command = commandsInQueue_m.takeFirst();
            send(command);
        }
    }
}
예제 #13
0
void IRCServer::sendCommandAsap(const QByteArray& command)
{
    qDebug() << command;
    if (isLoggedIn())
        send(command);
    else
    {
        commandsInQueue_m.push_back(command);
        enqueuedCommand();
    }
}
예제 #14
0
bool recordDatabase::updateRecord(Field field, int value, bool onlyIfGreater){
	if (isLoggedIn()){
		DatabaseEntry *prevValue[MAX_FIELDS];
		bool recordGotten = getRecord({ &field }, 1, prevValue);
		if (recordGotten && (!onlyIfGreater || prevValue[0]->intValue < value)){
			CString q = _T("");
			q.Format(_T("UPDATE accounts SET %s = %d WHERE %s = %d"), fieldNames[field], value, dbFieldNames[ID], id);
			rawQuery(q,NULL);
		}
	}
	return false;
}
예제 #15
0
파일: Ledger.cpp 프로젝트: SeijiEmery/hifi
bool Ledger::receiveAt(const QString& hfc_key, const QString& signing_key) {
    auto accountManager = DependencyManager::get<AccountManager>();
    if (!accountManager->isLoggedIn()) {
        qCWarning(commerce) << "Cannot set receiveAt when not logged in.";
        QJsonObject result{ { "status", "fail" }, { "message", "Not logged in" } };
        emit receiveAtResult(result);
        return false; // We know right away that we will fail, so tell the caller.
    }

    signedSend("public_key", hfc_key.toUtf8(), signing_key, "receive_at", "receiveAtSuccess", "receiveAtFailure");
    return true; // Note that there may still be an asynchronous signal of failure that callers might be interested in.
}
예제 #16
0
/*
 * This is the standard destructor and needs to be virtual to make
 * sure that if we subclass off this the right destructor will be
 * called.
 */
CKIRCProtocol::~CKIRCProtocol()
{
	// first, kill the listener and free it
	setListener(NULL);
	// now handle the connection to the IRC server itself.
	if (isConnected()) {
		if (isLoggedIn()) {
			doQUIT("bye");
			setIsLoggedIn(false);
		}
		mCommPort.disconnect();
	}
}
예제 #17
0
파일: systray.cpp 프로젝트: jplsek/puush-qt
void Systray::activeWindowScreenshotTimed()
{
    if (!isLoggedIn())
        return;

    trayIcon->showMessage(tr("Select a window"),
                          tr("Taking a screenshot in ") + QString::number(defaultSelectionTimeout) + tr(" seconds..."),
                          QSystemTrayIcon::Information);

    numTime = defaultSelectionTimeout;
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateActiveMessage()));
    timer->start(1000);
}
예제 #18
0
파일: systray.cpp 프로젝트: jplsek/puush-qt
/**
 * Puush upload a file via the open file dialog.
 * @brief Systray::uploadFile
 */
void Systray::uploadFile()
{
    if (!isLoggedIn())
        return;

    QString fileName = QFileDialog::getOpenFileName(NULL, tr("Upload file"));

    if (fileName == "")
        return;

    Upload *u = new Upload(fileName);

    connect(u, SIGNAL(started()), this, SLOT(puushStarted()));
    connect(u, SIGNAL(finished(QString)), this, SLOT(puushDone(QString)));
}
예제 #19
0
bool recordDatabase::addUser(CString name, CString pass){
	try{
		CString q = _T("");
		q.Format(_T("INSERT INTO accounts (%s,%s) VALUES ('%s','%s');"), dbFieldNames[USERNAME], dbFieldNames[PASSWORD],name, pass);
		rawQuery(q,NULL);
		logIn(name, pass);
		if (isLoggedIn()){
			return true;
		}
	}
	catch (int e){
		id = -1;
		return false;
	}
}
예제 #20
0
bool recordDatabase::removeUser(){
	if (isLoggedIn()){
		try{
			CString q = _T("");
			q.Format(_T("DELETE FROM accounts WHERE %s=%d"), dbFieldNames[ID],id);
			rawQuery(q,NULL);
			logOut();
			return true;
		}
		catch (int e){
			return false;
		}
	}
	return false;
}
예제 #21
0
파일: systray.cpp 프로젝트: jplsek/puush-qt
void Systray::historyPlaceholder()
{
    historyMenu->clear();

    // Just put something in the history menu in case the menu doesn't get updated.
    QAction *none = new QAction();

    if (isLoggedIn(false))
        none->setText("Not fetched... Try left clicking the tray icon.");
    else
        none->setText("Not logged in...");

    none->setEnabled(false);
    historyMenu->addAction(none);
}
예제 #22
0
bool recordDatabase::logIn(CString name, CString pass){
	try{
		CString q = _T("");
		q.Format(_T("SELECT %d FROM accounts WHERE username == '%s' AND password == '%s';"),dbFieldNames[ID],name,pass);
		DatabaseEntry *results[MAX_RESULT_SIZE][MAX_FIELDS];
		//clearResults(results);
		rawQuery(q,results);
		if (results[0][0]->gotten){
			id = results[0][0]->intValue;
		}

		return isLoggedIn();
	}
	catch (int e){
		id = -1;
		return false;
	}
}
예제 #23
0
bool recordDatabase::getRecord(Field fields[], int numFields, DatabaseEntry *result[MAX_FIELDS]){
	if (isLoggedIn()){
		CString q = _T("");
		CString fieldsStr = _T("");
		for (int i = 0; i < numFields; i++){
			fieldsStr += fieldNames[fields[i]];
		}
		q.Format(_T("SELECT %s FROM accounts WHERE %s = %d"), fieldsStr, dbFieldNames[ID], id);

		DatabaseEntry *results[MAX_RESULT_SIZE][MAX_FIELDS];
		clearResults(results);
		rawQuery(q,results);

		result = results[0];
		return true;
	}
	return false;
}
예제 #24
0
파일: VKApi.cpp 프로젝트: JohnPoison/QVKApi
void VKApi::login() {
    if (isLoggedIn() || loginView) {
        return;
    }

    auto webView = new QWebView();
    webView->setAttribute(Qt::WA_DeleteOnClose, true);
    auto url = getLoginUrl();
    webView->load( url );

    connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(loginUrlChanged(const QUrl&)));
    connect(webView, &QWebView::destroyed, [this](){
        this->loginView = 0;
    });
    webView->show();

    loginView = webView;

}
예제 #25
0
void OKSocialPluginAndroid::logout()
{
    if (!isLoggedIn()) {
        return;
    }

    _accessToken.clear();
    _userID.clear();

    cocos2d::JniMethodInfo methodInfo;
    if (cocos2d::JniHelper::getStaticMethodInfo(methodInfo, HELPER_CLASS_NAME, "logout", "(Z)V"))
    {
        methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (jboolean)_debug);
        methodInfo.env->DeleteLocalRef(methodInfo.classID);
    }

    if (_delegate)
        _delegate->onLogout({SocialPluginDelegate::Error::Type::SUCCESS, 0, ""});
}
예제 #26
0
void LoginDialog::toggleAction() {
    auto accountManager = DependencyManager::get<AccountManager>();
    QAction* loginAction = Menu::getInstance()->getActionForOption(MenuOption::Login);
    Q_CHECK_PTR(loginAction);
    static QMetaObject::Connection connection;
    if (connection) {
        disconnect(connection);
    }

    if (accountManager->isLoggedIn()) {
        // change the menu item to logout
        loginAction->setText("Logout " + accountManager->getAccountInfo().getUsername());
        connection = connect(loginAction, &QAction::triggered, accountManager.data(), &AccountManager::logout);
    } else {
        // change the menu item to login
        loginAction->setText("Log In / Sign Up");
        connection = connect(loginAction, &QAction::triggered, [] { LoginDialog::showWithSelection(); });
    }
}
예제 #27
0
/*
 * This method will log out any logged in user and break the
 * established connection to the IRC host. This is useful
 * when "shutting down" as it takes care of all the
 * possibilities in one fell swoop.
 */
void CKIRCProtocol::disconnect()
{
	// first, stop the listener
	stopListener();

	// now handle the connection to the IRC server itself.
	if (isConnected()) {
		if (isLoggedIn()) {
			doQUIT("bye");
			setIsLoggedIn(false);
		}
		{
			CKStackLocker	lockem(&mCommPortMutex);
			mCommPort.disconnect();
		}
		// clear out all the channels we joined
		clearChannelList();
	}
}
예제 #28
0
/*
 * This method checks to see if the two CKIRCProtocols are equal to
 * one another based on the values they represent and *not* on the
 * actual pointers themselves. If they are equal, then this method
 * returns true, otherwise it returns false.
 */
bool CKIRCProtocol::operator==( const CKIRCProtocol & anOther ) const
{
	bool		equal = true;

	if ((getHostname() != anOther.getHostname()) ||
		(getPort() != anOther.getPort()) ||
		(mCommPort != anOther.mCommPort) ||
		(isLoggedIn() != anOther.isLoggedIn()) ||
		(getPassword() != anOther.getPassword()) ||
		(getNickname() != anOther.getNickname()) ||
		(getUserHost() != anOther.getUserHost()) ||
		(getUserServer() != anOther.getUserServer()) ||
		(getRealName() != anOther.getRealName()) ||
		(mChannelList != anOther.mChannelList) ||
		(mResponders != anOther.mResponders)) {
		equal = false;
	}

	return equal;
}
예제 #29
0
	ModResult OnCheckReady(LocalUser* user)
	{
		/*I'm afraid that using the normal xline methods would then result in this line being checked at the wrong time.*/
		if (!isLoggedIn(user))
		{
			XLine* locallines = ServerInstance->XLines->MatchesLine("A", user);
			XLine* globallines = ServerInstance->XLines->MatchesLine("GA", user);
			if (locallines)
			{
				user->WriteServ("NOTICE %s :*** NOTICE -- You need to identify via SASL to use this server (your host is A-Lined).", user->nick.c_str());
				ServerInstance->Users->QuitUser(user, "A-Lined: "+locallines->reason);
				return MOD_RES_DENY;
			}
			else if (globallines)
			{
				user->WriteServ("NOTICE %s :*** NOTICE -- You need to identify via SASL to use this server (your host is GA-Lined).", user->nick.c_str());
				ServerInstance->Users->QuitUser(user, "GA-Lined: "+globallines->reason);
				return MOD_RES_DENY;
			}
		}
		return MOD_RES_PASSTHRU;
	}
예제 #30
0
void Player::changeTier(quint8 teamNum, const QString &newtier)
{
    if (!isLoggedIn()) {
        return;
    }

    if (teamNum >= teamCount()) {
        return;
    }
    if (team(teamNum).tier == newtier)
        return;
    if (battling()) {
        sendMessage(tr("You can't change tiers while battling."));
        return;
    }
    if (!TierMachine::obj()->exists(newtier)) {
        sendMessage(tr("The tier %1 doesn't exist!").arg(newtier));
        return;
    }
    if (!TierMachine::obj()->isValid(team(teamNum), newtier)) {
        Tier *tier = &TierMachine::obj()->tier(newtier);

        if (!tier->allowGen(team(teamNum).gen)) {
            sendMessage(tr("The generation of your team (%1) is invalid for the tier %2 which is in generation %3.").arg(GenInfo::Version(team(teamNum).gen), tier->name(), GenInfo::Version(tier->gen())));
            return;
        }

        QList<int> indexList;
        for(int i = 0; i < 6; i++) {
            if (tier->isBanned(team(teamNum).poke(i))) {
                indexList.append(i);
            }
        }

        if (indexList.size() > 0) {
            foreach(int i, indexList) {
                sendMessage(tr("The Pokemon '%1' is banned on tier '%2' for the following reasons: %3").arg(PokemonInfo::Name(team(teamNum).poke(i).num()), newtier,
                                                                                                            tier->bannedReason(team(teamNum).poke(i))));
            }