void handle_delete_character( Network::Client* client, PKTIN_83* msg ) { u32 charidx = cfBEu32( msg->charidx ); if ( ( charidx >= Plib::systemstate.config.character_slots ) || ( client->acct == nullptr ) || ( client->acct->get_character( charidx ) == nullptr ) ) { send_login_error( client, LOGIN_ERROR_MISC ); client->Disconnect(); return; } Accounts::Account* acct = client->acct; Mobile::Character* chr = acct->get_character( charidx ); if ( chr->client != nullptr || ( !Plib::systemstate.config.allow_multi_clients_per_account && acct->has_active_characters() ) ) { send_login_error( client, LOGIN_ERROR_OTHER_CHAR_INUSE ); client->Disconnect(); return; } if ( can_delete_character( chr, DELETE_BY_PLAYER ) ) { call_ondelete_scripts( chr ); delete_character( acct, chr, charidx ); } send_start( client ); }
void XTelepathyPasswordAuthOperation::storeCredentials(const QString &secret) { QString username = m_account->parameters().value(QStringLiteral("account")).toString(); Accounts::Manager *manager = KAccounts::accountsManager(); Accounts::Account *account = manager->account(m_accountStorageId); SignOn::Identity *identity; if (account) { Accounts::AccountService *service = new Accounts::AccountService(account, manager->service(QString()), this); Accounts::AuthData authData = service->authData(); identity = SignOn::Identity::existingIdentity(authData.credentialsId(), this); } else { // there's no valid KAccounts account, so let's try creating one QString providerName = QStringLiteral("ktp-"); providerName.append(m_account->serviceName()); qDebug() << "Creating account with providerName" << providerName; account = manager->createAccount(providerName); account->setDisplayName(m_account->displayName()); account->setValue("uid", m_account->objectPath()); account->setValue("username", username); account->setValue(QStringLiteral("auth/mechanism"), QStringLiteral("password")); account->setValue(QStringLiteral("auth/method"), QStringLiteral("password")); account->setEnabled(true); Accounts::ServiceList services = account->services(); Q_FOREACH(const Accounts::Service &service, services) { account->selectService(service); account->setEnabled(true); } }
void CalDavClient::startSlowSync() { FUNCTION_CALL_TRACE; if (!mManager) { mManager = new Accounts::Manager(this); } Accounts::Account *account = mManager->account(mAccountId); if (account != NULL) { mKCal::Notebook::Ptr notebook = mKCal::Notebook::Ptr(new mKCal::Notebook(account->displayName(), "")); notebook->setAccount(QString::number(mAccountId)); notebook->setPluginName(getPluginName()); notebook->setSyncProfile(getProfileName()); mKCal::ExtendedCalendar::Ptr calendar = mKCal::ExtendedCalendar::Ptr(new mKCal::ExtendedCalendar(KDateTime::Spec::UTC())); mKCal::ExtendedStorage::Ptr storage = calendar->defaultStorage(calendar); storage->open(); bool status = storage->addNotebook(notebook); LOG_DEBUG("NOTEBOOK created " << status << " UUID of NoteBook = " << notebook->uid()); storage->close(); calendar->close(); Report *report = new Report(mNAManager, &mSettings); mRequests.insert(report); connect(report, SIGNAL(finished()), this, SLOT(reportRequestFinished())); report->getAllEvents(); } }
bool accountExists(){ Accounts::Manager *manager; manager = new Accounts::Manager(); Accounts::AccountIdList accl = manager->accountList(); Accounts::Account *a; Accounts::ServiceList ss; for(int i =0; i<accl.length(); i++) { a = manager->account(accl[i]); ss = a->services(); for (int j=0; j<ss.length(); j++){ if(ss[j]->name()=="waxmpp"){ if(a->valueAsString("imsi") == Utilities::getImsi()){ return true; } } } } return false; }
void GetCredentialsJob::Private::getCredentials() { Accounts::Account *acc = manager->account(id); if (!acc) { qWarning() << "Unable to find account for id" << id; if (repeatedTries < 3) { qDebug() << "Retrying in 2s"; QTimer::singleShot(2000, q, SLOT(getCredentials())); repeatedTries++; } else { qDebug() << repeatedTries << "ending with error"; q->setError(KJob::UserDefinedError); q->setErrorText(QLatin1String("Could not find account")); q->emitResult(); } return; } Accounts::AccountService *service = new Accounts::AccountService(acc, manager->service(serviceType), q); Accounts::AuthData serviceAuthData = service->authData(); authData = serviceAuthData.parameters(); SignOn::Identity *identity = SignOn::Identity::existingIdentity(acc->credentialsId(), q); if (!identity) { qWarning() << "Unable to find identity for account id" << id; q->setError(KJob::UserDefinedError); q->setErrorText(QLatin1String("Could not find credentials")); q->emitResult(); return; } authData["AccountUsername"] = acc->value(QLatin1String("username")).toString(); QPointer<SignOn::AuthSession> authSession = identity->createSession(authMethod.isEmpty() ? serviceAuthData.method() : authMethod); if (!authSession) { qWarning() << "Unable to create auth session for" << authMethod << serviceAuthData.method(); q->setError(KJob::UserDefinedError); q->setErrorText(QLatin1String("Could not create auth session")); q->emitResult(); return; } QObject::connect(authSession.data(), &SignOn::AuthSession::response, [this, identity](const SignOn::SessionData &data) { sessionData = data; q->emitResult(); }); QObject::connect(authSession.data(), &SignOn::AuthSession::error, [this](const SignOn::Error &error) { qDebug() << error.message(); q->setError(KJob::UserDefinedError); q->setErrorText(error.message()); q->emitResult(); }); authSession->process(serviceAuthData.parameters(), authMechanism.isEmpty() ? serviceAuthData.mechanism() : authMechanism); }
/*! * \qmlmethod void AccountService::updateServiceEnabled(bool enabled) * * Enables or disables the service within the account configuration. * Since the \l enabled property is the combination of the global account's * enabledness status and the specific service's status, its value might not * change after this method is called. * * \sa enabled, serviceEnabled, autoSync */ void AccountService::updateServiceEnabled(bool enabled) { if (Q_UNLIKELY(accountService == 0)) return; Accounts::Account *account = accountService->account(); if (Q_UNLIKELY(account == 0)) return; account->selectService(accountService->service()); account->setEnabled(enabled); syncIfDesired(); }
QList <QSharedPointer<Account> > SystemPrivate::loadAccounts ( const QString & serviceType, bool includeCustomUI) { qDebug() << "PERF: LoadAccounts START"; QList <QSharedPointer<Account> > retList; Accounts::AccountIdList idList = m_accountsManager->accountList (serviceType); for (int i = 0; i < idList.size (); ++i) { Accounts::Account * aAccount = m_accountsManager->account (idList [i]); if (aAccount == 0) { qWarning() << "Null account received" << i + 1; continue; } Accounts::ServiceList sList = aAccount->services (serviceType); for (int j = 0; j < sList.size (); ++j) { Accounts::Service aService = sList [j]; aAccount->selectService (aService); qDebug() << "Service" << aService.displayName() << "found for" << "account" << aAccount->displayName(); QSharedPointer <Account> sAccount = QSharedPointer <Account> ( new Account); if (sAccount->init (idList [i], aService.name())) { bool append = true; if (includeCustomUI == false) { if (sAccount->service()->publishCustom() == Service::PUBLISH_CUSTOM_TOTAL) { append = false; } } if (append == true) { retList.append (sAccount); } } } delete aAccount; aAccount = 0; } qDebug() << "PERF: LoadAccounts END"; return retList; }
void QmlApplicationViewer::debugAccount(Accounts::AccountId id){ qDebug()<<"START DEBUG ACCT"; Accounts::Account *a; a = manager->account(id); qDebug()<<a->displayName(); qDebug()<<a->valueAsString("username"); qDebug()<<"END DEBUG ACCT"; }
void AccountService::syncIfDesired() { if (m_autoSync) { Accounts::Account *account = accountService->account(); if (Q_UNLIKELY(account == 0)) return; /* If needed, we could optimize this to call account->sync() when * re-entering the main loop, in order to reduce the number or writes. * But this would be better done in the Account class itself (and even * better, in libaccounts-glib). */ account->sync(); } }
/*! * \qmlproperty jsobject AccountService::provider * An immutable object representing the provider which provides the account. * The returned object will have at least these members: * \list * \li \c id is the unique identifier for this provider * \li \c displayName * \li \c iconName * \li \c isSingleAccount, \a true if this provider supports creating one * account at most * \li \c translations, the localization domain for translating the provider's * display name * \endlist */ QVariantMap AccountService::provider() const { QVariantMap map; if (Q_UNLIKELY(accountService == 0)) return map; Accounts::Account *account = accountService->account(); if (account == 0) return map; Accounts::Provider provider = account->provider(); map.insert("id", provider.name()); map.insert("displayName", provider.displayName()); map.insert("iconName", provider.iconName()); map.insert("isSingleAccount", provider.isSingleAccount()); map.insert("translations", provider.trCatalog()); return map; }
void SystemPrivate::accountsAccountCreated (Accounts::AccountId id) { // Safety check if (accountsListenerEnabled == false) { qDebug() << "Account created and ignored"; return; } //Check for sharing services under created account Accounts::Account * aAcc = m_accountsManager->account (id); if (aAcc == 0) { qWarning() << "Invalid account ID from Accounts Manager"; return; } if (aAcc->supportsService ("sharing") == false) { qDebug() << "Account created but without sharing support, ignored."; delete aAcc; return; } qDebug() << "Accounts' new account signal received" << id; Accounts::ServiceList services = aAcc->services ("sharing"); for (int i = 0; i < services.count(); ++i) { Accounts::Service aService = services.at (i); WebUpload::SharedAccount sAccount (new WebUpload::Account (0)); if (sAccount->init (aAcc->id(), aService.name()) == true) { qDebug() << "Emitting signal for new account" << sAccount->name(); Q_EMIT (newAccount(sAccount)); } } delete aAcc; }
void login2( Network::Client* client, PKTIN_91* msg ) // Gameserver login and character listing { client->encrypt_server_stream = true; if ( Network::is_banned_ip( client ) ) { send_login_error( client, LOGIN_ERROR_ACCOUNT_BLOCKED ); client->Disconnect(); return; } /* Hmm, might have to re-search for account. For now, we already have the account in client->acct. Might work different if real loginservers were used. */ Accounts::Account* acct = Accounts::find_account( msg->name ); if ( acct == nullptr ) { send_login_error( client, LOGIN_ERROR_NO_ACCOUNT ); client->Disconnect(); return; } // First check the password - if wrong, you can't find out anything else. bool correct_password = false; // dave changed 6/5/3, always authenticate with hashed user+pass std::string msgpass = msg->password; std::string acctname = acct->name(); std::string temp; Clib::MD5_Encrypt( acctname + msgpass, temp ); // MD5 correct_password = Clib::MD5_Compare( acct->passwordhash(), temp ); if ( !correct_password ) { send_login_error( client, LOGIN_ERROR_WRONG_PASSWORD ); client->Disconnect(); POLLOG.Format( "Incorrect password for account {} from {}\n" ) << acct->name() << client->ipaddrAsString(); return; } else { // write out cleartext if necessary if ( Plib::systemstate.config.retain_cleartext_passwords ) { if ( acct->password().empty() ) acct->set_password( msgpass ); } } if ( !acct->enabled() || acct->banned() ) { send_login_error( client, LOGIN_ERROR_ACCOUNT_BLOCKED ); client->Disconnect(); return; } // // Dave moved the max_clients check to pol.cpp so character cmdlevel could be checked. // POLLOG.Format( "Account {} logged in from {}\n" ) << acct->name() << client->ipaddrAsString(); // ENHANCEMENT: could authenticate with real loginservers. client->acct = acct; /* NOTE: acct->client is not set here. It is possible that another client is still connected, or a connection is stuck open, or similar. When a character is selected, if another client is connected, measures will be taken. */ // Tell the client about the starting locations and his characters (up to 5). // MuadDib Added new seed system. This is for transferring KR/6017/Normal client detection from // loginserver // to the gameserver. Allows keeping client flags from remote loginserver to gameserver for 6017 // and kr // packets. client->ClientType = cfBEu16( msg->unk3_4_ClientType ); send_start( client ); }
void loginserver_login( Network::Client* client, PKTIN_80* msg ) { unsigned idx; if ( Network::is_banned_ip( client ) ) { send_login_error( client, LOGIN_ERROR_ACCOUNT_BLOCKED ); client->Disconnect(); return; } Accounts::Account* acct = Accounts::find_account( msg->name ); if ( !acct ) { send_login_error( client, LOGIN_ERROR_NO_ACCOUNT ); client->Disconnect(); return; } else if ( Plib::systemstate.config.min_cmdlevel_to_login > acct->default_cmdlevel() ) { send_login_error( client, LOGIN_ERROR_MISC ); client->Disconnect(); return; } bool correct_password = false; std::string msgpass = msg->password; std::string acctname = acct->name(); std::string temp; Clib::MD5_Encrypt( acctname + msgpass, temp ); // MD5 correct_password = Clib::MD5_Compare( acct->passwordhash(), temp ); if ( !correct_password ) { send_login_error( client, LOGIN_ERROR_WRONG_PASSWORD ); client->Disconnect(); POLLOG.Format( "Incorrect password for account {} from {}\n" ) << acct->name() << client->ipaddrAsString(); return; } else { if ( Plib::systemstate.config.retain_cleartext_passwords ) { if ( acct->password().empty() ) acct->set_password( msgpass ); } } if ( !acct->enabled() || acct->banned() ) { send_login_error( client, LOGIN_ERROR_ACCOUNT_BLOCKED ); client->Disconnect(); return; } POLLOG_INFO.Format( "Account {} logged in from {}\n" ) << acct->name() << client->ipaddrAsString(); client->acct = acct; Network::PktHelper::PacketOut<Network::PktOut_A8> msgA8; msgA8->offset += 2; msgA8->Write<u8>( 0xFFu ); msgA8->offset += 2; // servcount unsigned short servcount = 0; for ( idx = 0; idx < networkManager.servers.size(); idx++ ) { ServerDescription* server = networkManager.servers[idx]; if ( !server->hostname.empty() ) { struct hostent* he = gethostbyname( server->hostname.c_str() ); // FIXME: here is a potential server lockup if ( he != nullptr && he->h_addr_list[0] ) { char* addr = he->h_addr_list[0]; server->ip[0] = addr[3]; server->ip[1] = addr[2]; server->ip[2] = addr[1]; server->ip[3] = addr[0]; } else { POLLOG.Format( "gethostbyname(\"{}\") failed for server {}\n" ) << server->hostname << server->name; continue; } } if ( server_applies( client, idx ) ) { ++servcount; msgA8->WriteFlipped<u16>( idx + 1u ); msgA8->Write( server->name.c_str(), 30 ); msgA8->WriteFlipped<u16>( idx + 1u ); msgA8->offset += 2; // u8 percentfull, s8 timezone msgA8->Write( server->ip, 4 ); } } u16 len = msgA8->offset; msgA8->offset = 1; msgA8->WriteFlipped<u16>( len ); msgA8->offset++; msgA8->WriteFlipped<u16>( servcount ); msgA8.Send( client, len ); if ( servcount == 0 ) { POLLOG.Format( "No applicable servers for client connecting from {}\n" ) << client->ipaddrAsString(); } }