QNetworkReply* Tracker::AuthPostJson( const QString& path, const QByteArray& data ) { #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QString credentials = "Basic " + ( Username() + ":" + Password() ).toLatin1().toBase64(); #else QString credentials = "Basic " + ( Username() + ":" + Password() ).toAscii().toBase64(); #endif QNetworkRequest request = CreateTrackerRequest( path ); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) request.setRawHeader( "Authorization", credentials.toLatin1() ); #else request.setRawHeader( "Authorization", credentials.toAscii() ); #endif request.setHeader( QNetworkRequest::ContentTypeHeader, "application/json" ); return mNetworkManager.post( request, data ); }
void Tracker::EnsureAccountIsSetUp() { if( !IsAccountSetUp() ) { LOG( "No account setup. Creating one for you." ); CreateAndStoreAccount(); } else { LOG( "Account %s found", Username().toStdString().c_str() ); } }
//SLOT void Gui_AdminWindow::removeUser() { try { _admin->removeUser(Username(_userInfo->info1().toStdString(), "")); }catch(Error e) { QMessageBox::critical(this, "Error", QString::fromStdString(e.errorMessage())); } emit modified(); }
void LinqAdmin::upgradeSubscription(const Username& usr, privLevel newlevel) { User* current = _db->find(usr); current->account()->setPrLevel(newlevel); current->account()->lastPayment()->setApprovation(true); current->account()->lastPayment()->setAppDate(QDate::currentDate()); Message m(Username("Linqedin",""), current->account()->username(), "Upgrade request", "Upgrade requested succesfully approved.",false); current->loadInMail(m); save(); }
void ChangeSubType::confirm() { if (!administrator->db->findbool(writeutente->text())) stato->setText("<font color='red'>Errore, utente non presente nel database</font>"); else if (seleziona_arrivo->currentText()==administrator->db->find(Username(writeutente->text()))->second->get_tipologia_utente()) { stato->setText("<font color='grey'>Errore, l'utente è già di questa tipologia</font>"); } else { administrator->changeSubscriptionType(Username(writeutente->text()),seleziona_arrivo->currentText()); administrator->save(); close(); QMessageBox msgBox; msgBox.setText("Operazione completata con successo."); msgBox.exec(); stato->setText("Da qui puoi modificare la tipologia di un utente nel database"); } }
// Login information void _Server::HandleLoginInfo(_Buffer &Data, _Peer *Peer) { // Read packet bool CreateAccount = Data.ReadBit(); std::string Username(Data.ReadString()); std::string Password(Data.ReadString()); uint64_t Secret = Data.Read<uint64_t>(); Username.resize(std::min(ACCOUNT_MAX_USERNAME_SIZE, Username.length())); Password.resize(std::min(ACCOUNT_MAX_PASSWORD_SIZE, Password.length())); // Validate singleplayer if(!Username.length() && !Password.length() && Secret != Save->GetSecret()) return; // Create account or login if(CreateAccount) { // Check for existing account if(Save->CheckUsername(Username)) { _Buffer Packet; Packet.Write<PacketType>(PacketType::ACCOUNT_EXISTS); Network->SendPacket(Packet, Peer); return; } else Save->CreateAccount(Username, Password); } // Get account id Peer->AccountID = Save->GetAccountID(Username, Password); // Make sure account exists _Buffer Packet; if(Peer->AccountID == 0) { Packet.Write<PacketType>(PacketType::ACCOUNT_NOTFOUND); } else { bool AccountInUse = false; for(auto &CheckPeer : Network->GetPeers()) { if(CheckPeer != Peer && CheckPeer->AccountID == Peer->AccountID) { AccountInUse = true; Peer->AccountID = 0; break; } } if(AccountInUse) Packet.Write<PacketType>(PacketType::ACCOUNT_INUSE); else Packet.Write<PacketType>(PacketType::ACCOUNT_SUCCESS); } Network->SendPacket(Packet, Peer); }
void MainWindow::SlotAutenticationUser(){ LinkedInClient* client=new LinkedInClient(Username(caselladitestoUserU->text().toStdString(),caselladitestoPwU->text().toStdString())); if (client->u!=0) {this->hide(); AccessoUtente*au=new AccessoUtente(client,this); au->show();} else {QMessageBox * m=new QMessageBox(); m->setText("Autenticazione non avvenuta"); m->exec();} }
void Gui_Admin::removeUser(){ QListWidgetItem* curr = usersList->currentItem(); try{ db->removeUser(Username(curr->text().toStdString())); db->save(); usersList->takeItem(usersList->currentRow()); } catch(MyExc e){ QMessageBox* msg = new QMessageBox(); msg->setText(QString::fromStdString(e.errorMsg())); msg->show(); } }
//SLOT void Gui_Groups::sendPost() { QString pst = newpost->toPlainText(); Group g(Username(admin.toStdString(), ""), name.toStdString()); if(!pst.isEmpty()) { Post* p = new Post(_client->username(), pst.toStdString()); _client->addPostToGroup(g, *p); QString dump = showgrp->toHtml(); QString me = QString::fromStdString(_client->username().login()); dump.append(QString("<h5>Author: <span style='font-weight:400;font-size:10px'>" + me + "</span></h5><p style='font-weight:400;font-size:11px;'>" + pst + "</p><hr>")); showgrp->setHtml(dump); _client->save(); } }
void LinQedInAdmin::insert(QString username, QString tipoutente, QString name, QString cognome, QString citta, QString lavori, QString datanascita,QString lingue, QString telefono,QString email) { Utente* valore=new Utente(Username(username)); valore->info=new Info; valore->rete=new Rete; valore->info->Citta=citta; valore->info->Cognome=cognome; valore->info->data_nascita=datanascita; valore->info->lavori=lavori; valore->info->Nome=name; valore->info->lingue=lingue; valore->info->telefono=telefono; valore->info->email=email; valore->tipologia_utente=tipoutente; db->db.insert(std::pair<QString,Utente*>(username,valore)); }
Username LinkedDB::getAdmin() const{ QString val; QFile file; file.setFileName("db.json"); if (!file.exists()) { throw MyExc(database, "db file does not exists!"); } if (!file.open(QIODevice::ReadOnly)) { throw MyExc(database, "problem reading the file!"); } val = file.readAll(); file.close(); QJsonDocument doc = QJsonDocument::fromJson(val.toUtf8()); QJsonObject all_json = doc.object(); QJsonObject admin = all_json["admin"].toObject(); return (Username(admin["username"].toString().toStdString(), admin["password"].toString().toStdString())); }
//SLOT void Gui_AdminWindow::showSearchResult() { if(it != res.end()) { _userInfo->setInfo1(QString::fromStdString(it->first)); _cnt = _userInfo->info1(); tbar->actions().at(0)->setVisible(true); tbar->actions().at(1)->setVisible(false); tbar->actions().at(3)->setVisible(false); if(res.size() > 1 && it != res.end()) tbar->actions().at(2)->setVisible(true); QString htmloutput = QString("<span style='color: #666'>( " + QString::fromStdString(it->first) + " )</span>" + QString::fromStdString(it->second)); std::list<Group*> lsg = _admin->listUserGroups(Username(it->first, "")); if(lsg.size() > 0) { htmloutput.append("<h4>Groups</h4><ul style='font-weight:400'>"); for(std::list<Group*>::iterator j = lsg.begin(); j != lsg.end(); ++j) htmloutput += "<li>" + QString::fromStdString((*j)->name()) + "</li>"; htmloutput.append("</ul>"); } _userInfo->setHtml(htmloutput); } else _userInfo->setHtml("<h2>End</h2>"); }
//SLOT void Gui_AdminWindow::showUser() { QString _sel = _userList->currentItem()->data(Qt::UserRole + 1).toString(); std::list<Group*> lsg = _admin->listUserGroups(Username(_userList->currentItem()->data(Qt::UserRole + 2).toString().toStdString(), "")); if(lsg.size() > 0) { _sel.append("<h4>Groups</h4><ul style='font-weight:400'>"); for(std::list<Group*>::iterator j = lsg.begin(); j != lsg.end(); ++j) _sel += "<li>" + QString::fromStdString((*j)->name()) + "</li>"; _sel.append("</ul>"); } _userInfo->setHtml(_sel); _userInfo->setInfo1(_userList->currentItem()->data(Qt::UserRole + 2).toString()); if(tbar->isHidden()) tbar->show(); tbar->actions().at(3)->setVisible(false); tbar->actions().at(2)->setVisible(false); tbar->actions().at(0)->setVisible(true); if(_userList->currentItem()->data(Qt::UserRole + 3) == 1) { tbar->actions().at(1)->setVisible(true); _userInfo->setInfo2(_userList->currentItem()->data(Qt::UserRole + 4).toString()); } else tbar->actions().at(1)->setVisible(false); }
// --------------------------------------------------------- // RFavouritesSrvTable::ReadItemDataL // --------------------------------------------------------- // void RFavouritesSrvTable::ReadItemDataL( CFavouritesItemImpl& aItem ) const { // Fill standard attributes. aItem.SetUid( Uid() ); // No bookmark can exist with the Null Uid. __ASSERT_DEBUG( aItem.Uid() != KFavouritesNullUid, FavouritesPanic( EFavouritesNullUidInDatabase ) ); aItem.SetParentFolder( ParentFolder() ); aItem.SetType( Type() ); aItem.SetNameL( Name() ); HBufC* url = UrlLC(); aItem.SetUrlL( *url ); CleanupStack::PopAndDestroy(); // url aItem.SetUserNameL( Username() ); aItem.SetPasswordL( Password() ); aItem.SetWapAp( WapAp() ); aItem.SetFactoryItem( FactoryItem() ); aItem.SetReadOnly( ReadOnly() ); aItem.SetContextId( ContextId() ); aItem.SetModified( Modified() ); aItem.SetHidden( Hidden() ); }
//SLOT void Gui_AdminWindow::upgradeUser() { _admin->upgradeSubscription(Username(_userInfo->info1().toStdString(), ""), (privLevel) ((_userInfo->info2().toInt()))); QMessageBox::information(this, "Operation successful", "Upgrade request succesfully approved."); emit modified(); }