void PublicHubsFrame::updateList() { //CLockRedraw<> l_lock_draw(m_ctrlHubs); m_ctrlHubs.DeleteAllItems(); users = 0; visibleHubs = 0; double size = -1; FilterModes mode = NONE; int sel = ctrlFilterSel.GetCurSel(); bool doSizeCompare = parseFilter(mode, size); auto cnt = m_ctrlHubs.GetItemCount(); for (auto i = m_hubs.cbegin(); i != m_hubs.cend(); ++i) { if (matchFilter(*i, sel, doSizeCompare, mode, size)) { TStringList l; l.resize(COLUMN_LAST); l[COLUMN_NAME] = Text::toT(i->getName()); string l_description = i->getDescription(); boost::replace_all(l_description, ".px.", ""); l[COLUMN_DESCRIPTION] = Text::toT(l_description); l[COLUMN_USERS] = Util::toStringW(i->getUsers()); l[COLUMN_SERVER] = Text::toT(i->getServer()); l[COLUMN_COUNTRY] = Text::toT(i->getCountry()); // !SMT!-IP l[COLUMN_SHARED] = Util::formatBytesW(i->getShared()); l[COLUMN_MINSHARE] = Util::formatBytesW(i->getMinShare()); l[COLUMN_MINSLOTS] = Util::toStringW(i->getMinSlots()); l[COLUMN_MAXHUBS] = Util::toStringW(i->getMaxHubs()); l[COLUMN_MAXUSERS] = Util::toStringW(i->getMaxUsers()); l[COLUMN_RELIABILITY] = Util::toStringW(i->getReliability()); l[COLUMN_RATING] = Text::toT(i->getRating()); const auto l_country = i->getCountry(); dcassert(!l_country.empty()); const auto l_index_country = WinUtil::getFlagIndexByName(l_country.c_str()); //const auto l_index = m_ctrlHubs.insert(cnt++, l, l_index_country); // !SMT!-IP /* LVITEM lvItem = { 0 }; lvItem.mask = LVIF_IMAGE; lvItem.iItem = l_index; lvItem.iImage = isOnline(i->getServer()) ? 0 : 1; m_ctrlHubs.SetItem(&lvItem); */ visibleHubs++; users += i->getUsers(); } } m_ctrlHubs.resort(); updateStatus(); }
User getUser(const Api &api, std::string id, std::string login) { if(!id.empty()) { return getUsers(api, {id}, {})[0]; } else if(!login.empty()) { return getUsers(api, {}, {login})[0]; } else { throw TwitchException("Either login or user id should be specified!"); } }
void FetchFriends::run() { replyMsg = ""; success = twitObj->friendsIdsGet(twitObj->getTwitterUsername()); if(!success) return; twitObj->getLastWebResponse( replyMsg ); std::vector<std::string> IDs = getIDs( replyMsg ); success = twitObj->userLookup(IDs, true); if(!success) return; twitObj->getLastWebResponse( replyMsg ); friends = getUsers( replyMsg ); HTTPRequest req; req.init(); req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword()); for(int i=0 ; i<friends.size() ; i++) { std::string img; friendAvatars.push_back(""); if(req.GET(friends[i].getProfileImgURL(), img)) friendAvatars[i] = img; else { LOG4CXX_INFO(logger, "Warning: Couldn't fetch Profile Image for " << user << "'s friend " << friends[i].getScreenName()) } } }
void MainWindow::initUI() { getUsers(); ui->UsersList->clear(); QString autoLogUser = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "AUTO_LOGIN_USER"); for (int i=0; i<mvUsers.size(); i++) { ui->UsersList->addItem(mvUsers[i]); if ( autoLogUser == mvUsers[i] ) ui->UsersList->setCurrentIndex(i); } QString autoLog = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "ENABLE_AUTO_LOGIN"); if ( autoLog == "TRUE" ) { ui->AutoLoginEnabledCB->setChecked(true); ui->UsersList->setEnabled(true); } else { ui->AutoLoginEnabledCB->setChecked(false); ui->UsersList->setEnabled(false); } ui->EnableVNC->setChecked(false); QString vnc = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "ALLOW_REMOTE_LOGIN"); if ( vnc == "TRUE" ) ui->EnableVNC->setChecked(true); ui->checkShowPW->setChecked(false); QString showpw = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "ENABLE_VIEW_PASSWORD_BUTTON"); if ( showpw == "TRUE" ) ui->checkShowPW->setChecked(true); ui->SaveButton->setEnabled(false); }
void MainWindow::on_delUser_triggered() { // show ui to disp all common accounts DelUserWnd *wnd = new DelUserWnd; ui->tabWidget->addTab (wnd,QString(tr("创建用户"))); ui->tabWidget->setCurrentWidget (wnd); //ui->tabWidget->setTabEnabled(ui->tabWidget->currentIndex(),false); connect(wnd,SIGNAL(delAction(DelUserWnd*)),SIGNAL(delUsers(DelUserWnd*))); //connect(wnd,SIGNAL(dataOk()),SLOT(enableCurrentTab())); emit getUsers(wnd); }
void Msg::sendmsgCmd(const QString& from, const QStringList& list) { if(list[0].startsWith("@")) { QStringList users = getUsers(list[0]); QStringList newlist(list); newlist[1] = "[" + list[0] + "] " + list[1]; for(QStringList::ConstIterator it = users.begin(); it != users.end(); ++it) { newlist[0] = *it; sendmsgUser(from,newlist,true); } QString txt("You send a message to " + list[0] + ": " + list[1]); manager()->connectionPlugin()->serverSend(from,txt); } else sendmsgUser(from,list); }
mongo::ListSessionsSpec mongo::listSessionsParseSpec(StringData stageName, const BSONElement& spec) { uassert(ErrorCodes::TypeMismatch, str::stream() << stageName << " options must be specified in an object, but found: " << typeName(spec.type()), spec.type() == BSONType::Object); IDLParserErrorContext ctx(stageName); auto ret = ListSessionsSpec::parse(ctx, spec.Obj()); uassert(ErrorCodes::UnsupportedFormat, str::stream() << stageName << " may not specify {allUsers:true} and {users:[...]} at the same time", !ret.getAllUsers() || !ret.getUsers() || ret.getUsers()->empty()); // Verify that the correct state is set on the client. uassert( 31106, str::stream() << "The " << DocumentSourceListLocalSessions::kStageName << "stage is not allowed in this context :: missing an AuthorizationManager", AuthorizationManager::get(Client::getCurrent()->getServiceContext())); uassert( 31111, str::stream() << "The " << DocumentSourceListLocalSessions::kStageName << "stage is not allowed in this context :: missing a LogicalSessionCache", LogicalSessionCache::get(Client::getCurrent()->getOperationContext())); if (!ret.getAllUsers() && (!ret.getUsers() || ret.getUsers()->empty())) { // Implicit request for self const auto& userName = getUserNameForLoggedInUser(Client::getCurrent()->getOperationContext()); ret.setUsers(std::vector<ListSessionsUser>({userName})); } return ret; }
ImpersonationSessionGuard::ImpersonationSessionGuard(OperationContext* opCtx) : _opCtx(opCtx) { auto authSession = AuthorizationSession::get(_opCtx->getClient()); const auto impersonatedUsersAndRoles = rpc::getImpersonatedUserMetadata(opCtx); if (impersonatedUsersAndRoles) { uassert(ErrorCodes::Unauthorized, "Unauthorized use of impersonation metadata.", authSession->isAuthorizedForPrivilege( Privilege(ResourcePattern::forClusterResource(), ActionType::impersonate))); fassert(ErrorCodes::InternalError, !authSession->isImpersonating()); authSession->setImpersonatedUserData(impersonatedUsersAndRoles->getUsers(), impersonatedUsersAndRoles->getRoles()); _active = true; return; } }
vector<User> UserDao::getCandidatesForIdUser(string idUser){ /**Busco los candidatos del usuario indicado**/ vector<User> users = getUsers(); if (idUser.empty()){ return users; } vector<User> usersOk; for (User user : users){ if (idUser.compare(user.getId().c_str()) != 0){ usersOk.push_back(user); } } return usersOk; }
/** * Reload the user/passwd form mysql.user table into the service users' hashtable * environment. * * @param service The current service * @return -1 on any error or the number of users inserted (0 means no users at all) */ int reload_mysql_users(SERVICE *service) { int i; struct users *newusers, *oldusers; if ((newusers = mysql_users_alloc()) == NULL) return 0; i = getUsers(service, newusers); spinlock_acquire(&service->spin); oldusers = service->users; service->users = newusers; spinlock_release(&service->spin); users_free(oldusers); return i; }
/** * Replace the user/passwd form mysql.user table into the service users' hashtable * environment. * The replacement is succesful only if the users' table checksums differ * * @param service The current service * @return -1 on any error or the number of users inserted (0 means no users at all) */ int replace_mysql_users(SERVICE *service) { int i; struct users *newusers, *oldusers; if ((newusers = mysql_users_alloc()) == NULL) return -1; i = getUsers(service, newusers); if (i <= 0) return i; spinlock_acquire(&service->spin); oldusers = service->users; /* digest compare */ if (memcmp(oldusers->cksum, newusers->cksum, SHA_DIGEST_LENGTH) == 0) { /* same data, nothing to do */ LOGIF(LD, (skygw_log_write_flush( LOGFILE_DEBUG, "%lu [replace_mysql_users] users' tables not switched, checksum is the same", pthread_self()))); /* free the new table */ users_free(newusers); i = 0; } else { /* replace the service with effective new data */ LOGIF(LD, (skygw_log_write_flush( LOGFILE_DEBUG, "%lu [replace_mysql_users] users' tables replaced, checksum differs", pthread_self()))); service->users = newusers; } spinlock_release(&service->spin); if (i) users_free(oldusers); return i; }
void Msg::unsubscribeCmd(const QString& from, const QStringList& list) { QString listname = list[0]; QStringList l = getUsers(listname); l.removeAll(from); QFile f(manager()->dataDir() + "/msg/" + listname); if (l.count()) { if (!f.open(QIODevice::WriteOnly)) { octInfo("Could not write message file.\n"); return; } QTextStream stream2(&f); for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) stream2 << (*it + "\n"); f.close(); } else f.remove(); QString txt("You unsubscribed from list " + listname); manager()->connectionPlugin()->serverSend(from,txt); }
// a != b → R( a, i_{a,b} ) = R( b, i_{a,b} ) void Egraph::ExtAxiom( Enode * a, Enode * b ) { assert( isDynamic( a ) ); assert( isDynamic( b ) ); Enode * as = dynamicToStatic( a ); Enode * bs = dynamicToStatic( b ); assert( isStatic( as ) ); assert( isStatic( bs ) ); assert( as->isDTypeArray( ) ); assert( bs->isDTypeArray( ) ); // create fresh index i_a,b for pair a,b char def_name[ 48 ]; sprintf( def_name, IND_STR, as->getId( ), bs->getId( ) ); const unsigned type = DTYPE_ARRAY_INDEX; if ( lookupSymbol( def_name ) == NULL ) newSymbol( def_name, type ); // Create new variable Enode * i = mkVar( def_name ); // Create two new selections Enode * select1 = mkSelect( as, i ); Enode * select2 = mkSelect( bs, i ); // Create new literals Enode * lit1 = mkEq( cons( as, cons( bs ) ) ); Enode * lit2_pos = mkEq( cons( select1, cons( select2 ) ) ); Enode * lit2 = mkNot( cons( lit2_pos ) ); #ifdef PRODUCE_PROOF if ( config.gconfig.print_inter > 0 ) { const uint64_t shared = getIPartitions( as ) & getIPartitions( bs ); // Mixed can't be one at this point assert( shared != 1 ); // Set AB-mixed partition if no intersection if ( shared == 0 ) { setIPartitions( i, 1 ); setIPartitions( select1, 1 ); setIPartitions( select2, 1 ); setIPartitions( lit1, 1 ); setIPartitions( lit2_pos, 1 ); setIPartitions( lit2, 1 ); } // Otherwise they share something else { setIPartitions( i, shared ); setIPartitions( select1, shared ); setIPartitions( select2, shared ); setIPartitions( lit1, shared ); setIPartitions( lit2_pos, shared ); setIPartitions( lit2, shared ); } } #endif vector< Enode * > v; v.push_back( lit1 ); v.push_back( lit2 ); #ifdef ARR_VERB cout << "Axiom Ext -> " << "( or " << lit1 << " " << lit2 << " )" << endl; #endif splitOnDemand( v, id ); handleArrayAssertedAtomTerm( select1 ); handleArrayAssertedAtomTerm( select2 ); // New contexts to propagate info about new index // Given R(a,new) look for all store users W(a,i,e) // and instantiate RoW over R(W(a,i,e),new) vector< Enode * > sela; vector< Enode * > stoa; vector< Enode * > selb; vector< Enode * > stob; Enode * select3 = NULL; // Act over a getUsers( a, sela, stoa ); for( size_t j = 0 ; j < stoa.size( ) ; j++ ) { assert( isDynamic( stoa[ j ] ) ); Enode * ss = dynamicToStatic( stoa[ j ] ); assert( isStatic( ss ) ); // Creation new select for each store user of a select3 = mkSelect( ss, i ); // RoW over new select handleArrayAssertedAtomTerm( select3 ); #ifdef PRODUCE_PROOF if ( config.gconfig.print_inter > 0 ) { const uint64_t shared = getIPartitions( ss ) & getIPartitions( i ); // Mixed can't be one at this point assert( shared != 1 ); // Set AB-mixed partition if no intersection if ( shared == 0 ) setIPartitions( select3, 1 ); // Otherwise they share something else setIPartitions( select3, shared ); } #endif } // Act over b getUsers( b, selb, stob ); for ( size_t j = 0 ; j < stob.size( ) ; j++ ) { assert( isDynamic( stoa[ j ] ) ); Enode * ss = dynamicToStatic( stob[ j ] ); assert( isStatic( ss ) ); // Creation new select for each store user of b select3 = mkSelect( ss, i ); #ifdef PRODUCE_PROOF if ( config.gconfig.print_inter > 0 ) { const uint64_t shared = getIPartitions( ss ) & getIPartitions( i ); // Mixed can't be one at this point assert( shared != 1 ); // Set AB-mixed partition if no intersection if ( shared == 0 ) setIPartitions( select3, 1 ); // Otherwise they share something else setIPartitions( select3, shared ); } #endif // RoW over new select handleArrayAssertedAtomTerm( select3 ); } }
void Egraph::handleArrayMerge( Enode * x, Enode * y ) { assert( ( x->isDTypeArray( ) && y->isDTypeArray( ) ) || ( x->isDTypeArrayElement( ) && y->isDTypeArrayElement( ) ) ); vector< Enode * > xSelUsers, xStoUsers; getUsers( x, xSelUsers, xStoUsers ); vector<Enode * >::iterator xSelUsersIt; vector<Enode * >::iterator xStoUsersIt; vector< Enode * > ySelUsers, yStoUsers; getUsers( y, ySelUsers, yStoUsers ); vector<Enode * >::iterator ySelUsersIt; vector<Enode * >::iterator yStoUsersIt; #ifdef ARR_VERB_POSTMERGE cout << endl << "Getting x and y equivalence class users: " << endl; cout << "Equivalence class of x is: " << endl; Enode * aux=x; do { cout << aux << " "; aux=aux->getNext(); } while(aux!=x); cout << endl << "Here are x class select users: " << endl; for ( xSelUsersIt = xSelUsers.begin( ); xSelUsersIt != xSelUsers.end( ); xSelUsersIt++ ) {cout << *xSelUsersIt << " ";} cout << endl << "Here are x class store users: " << endl; for ( xStoUsersIt = xStoUsers.begin( ); xStoUsersIt != xStoUsers.end( ); xStoUsersIt++ ) {cout << *xStoUsersIt << " ";} cout << endl << "Equivalence class of y is: " << endl; aux=y; do { cout << aux << " "; aux=aux->getNext(); } while(aux!=y); cout << endl << "Here are y class select users: " << endl; for ( ySelUsersIt = ySelUsers.begin( ); ySelUsersIt != ySelUsers.end( ); ySelUsersIt++ ) {cout << *ySelUsersIt << " ";} cout << endl << "Here are y class store users: " << endl; for ( yStoUsersIt = yStoUsers.begin( ); yStoUsersIt != yStoUsers.end( ); yStoUsersIt++ ) {cout << *yStoUsersIt << " ";} cout << endl << endl; #endif Enode * z, * zIndex; // , * zElement, * zArray, // TODO join all the cases together for more efficiency // NB x,y are elements of equivalence classes X,Y, we need to scan X or Y looking for store terms if( y->isDTypeArray() ) { // Case 1: x is b, y is W(a,i,e), exists z as R(b,j) // Scan all R(b,j) for ( xSelUsersIt = xSelUsers.begin( ) ; xSelUsersIt != xSelUsers.end( ) ; xSelUsersIt++ ) { z = * xSelUsersIt; zIndex = z->get2nd( ); // scan Y looking for store terms Enode * YElem = y; do { if( YElem->isStore( ) ) { #ifdef ARR_VERB cout << "Arrow down B: " << x << " W(A,I,E): " << YElem << " R(B,J): " << z << endl; #endif // create new term R(W(a,i,e),j) Enode * s_yelem = dynamicToStatic( YElem ); Enode * s_z2nd = dynamicToStatic( z->get2nd( ) ); Enode * select = mkSelect( s_yelem, s_z2nd ); #ifdef PRODUCE_PROOF if ( config.gconfig.print_inter > 0 ) { const uint64_t shared = getIPartitions( s_yelem ) & getIPartitions( s_z2nd ); // Mixed can't be one at this point assert( shared != 1 ); // Set AB-mixed partition if no intersection if ( shared == 0 ) setIPartitions( select, 1 ); // Otherwise they share something else setIPartitions( select, shared ); } #endif handleArrayAssertedAtomTerm( select ); } YElem = YElem->getNext( ); } while ( YElem != y ); } /*// Case 2: x is b, y is W(a,i,e), exists z as W(b,j,f) // Scan all W(b,j,f) for (xStoUsersIt=xStoUsers.begin(); xStoUsersIt<xStoUsers.end(); xStoUsersIt++) { z=*xStoUsersIt; zElement=z->get3rd(); zIndex=z->get2nd(); // create new term W(W(a,i,e),j,f) newSto=mkStore(y,zIndex,zElement,present); // TODO check if term already seen in a previous assertion on the current path // deduce clauses for the new store newArrayDed(newSto); }*/ } if( x->isDTypeArray() ) { // Case 1 reverse: y is b, x is W(a,i,e), exists z as R(b,j) // Scan all R(b,j) for ( ySelUsersIt = ySelUsers.begin( ) ; ySelUsersIt != ySelUsers.end( ) ; ySelUsersIt++ ) { z = *ySelUsersIt; zIndex = z->get2nd( ); // scan X looking for store terms Enode * XElem = x; do { if( XElem->isStore( ) ) { #ifdef ARR_VERB cout << "Arrow down B: " << XElem << " W(A,I,E): " << y << " R(B,J): " << z << endl; #endif // Create new term R(W(a,i,e),j) from static version Enode * s_xelem = dynamicToStatic( XElem ); Enode * s_z2nd = dynamicToStatic( z->get2nd( ) ); Enode * select = mkSelect( s_xelem, s_z2nd ); #ifdef PRODUCE_PROOF if ( config.gconfig.print_inter > 0 ) { const uint64_t shared = getIPartitions( s_xelem ) & getIPartitions( s_z2nd ); // Mixed can't be one at this point assert( shared != 1 ); // Set AB-mixed partition if no intersection if ( shared == 0 ) setIPartitions( select, 1 ); // Otherwise they share something else setIPartitions( select, shared ); } #endif handleArrayAssertedAtomTerm( select ); } XElem = XElem->getNext( ); } while ( XElem != x ); } /*// Case 2 reverse: y is a term b of type array, x is a Store W(a,i,e), exists z as W(b,j,f) // Scan all W(b,j,f) for (yStoUsersIt=yStoUsers.begin(); yStoUsersIt<yStoUsers.end(); yStoUsersIt++) { z=*yStoUsersIt; zElement=z->get3rd(); zIndex=z->get2nd(); // create new term W(W(a,i,e),j,f) newSto=mkStore(y,zIndex,zElement,present); // TODO check if term already seen in a previous assertion on the current path // deduce clauses for the new store newArrayDed(newSto); }*/ } Enode * w; if( x->isDTypeArray( ) && y->isDTypeArray( ) ) { //Case 3: x is a term a of type array, y is a term b of type array, exist z as W(a,i,e) and w as R(b,j) //scan all W(a,i,e) and R(b,j) for ( ySelUsersIt = ySelUsers.begin( ) ; ySelUsersIt < ySelUsers.end( ) ; ySelUsersIt++ ) { for ( xStoUsersIt = xStoUsers.begin( ) ; xStoUsersIt < xStoUsers.end( ) ; xStoUsersIt++ ) { w = *ySelUsersIt; z = *xStoUsersIt; #ifdef ARR_VERB cout << "Arrow up A: " << x << " B: " << y << " W(A,I,E): " << z << " R(B,J): " << w << endl; #endif // create new term R(W(a,i,e),j) Enode * s_z = dynamicToStatic( z ); Enode * s_w2nd = dynamicToStatic( w->get2nd( ) ); Enode * select = mkSelect( s_z, s_w2nd ); #ifdef PRODUCE_PROOF if ( config.gconfig.print_inter > 0 ) { const uint64_t shared = getIPartitions( s_z ) & getIPartitions( s_w2nd ); // Mixed can't be one at this point assert( shared != 1 ); // Set AB-mixed partition if no intersection if ( shared == 0 ) setIPartitions( select, 1 ); // Otherwise they share something else setIPartitions( select, shared ); } #endif handleArrayAssertedAtomTerm( select ); } } //Case 3 reverse: y is a term a of type array, x is a term b of type array, exist z as W(a,i,e) and w as R(b,j) //scan all W(a,i,e) and R(b,j) for ( xSelUsersIt = xSelUsers.begin( ) ; xSelUsersIt < xSelUsers.end( ) ; xSelUsersIt++ ) { for ( yStoUsersIt = yStoUsers.begin( ) ; yStoUsersIt < yStoUsers.end( ) ; yStoUsersIt++) { w = *xSelUsersIt; z = *yStoUsersIt; #ifdef ARR_VERB cout << "Arrow up A: " << x << " B: " << y << " W(A,I,E): "<< z << " R(B,J): " << w << endl; #endif // create new term R(W(a,i,e),j) Enode * s_z = dynamicToStatic( z ); Enode * s_w2nd = dynamicToStatic( w->get2nd( ) ); Enode * select = mkSelect( s_z, s_w2nd ); #ifdef PRODUCE_PROOF if ( config.gconfig.print_inter > 0 ) { const uint64_t shared = getIPartitions( s_z ) & getIPartitions( s_w2nd ); // Mixed can't be one at this point assert( shared != 1 ); // Set AB-mixed partition if no intersection if ( shared == 0 ) setIPartitions( select, 1 ); // Otherwise they share something else setIPartitions( select, shared ); } #endif handleArrayAssertedAtomTerm( select ); } } } /*//Case 4: x is a term e of type element, y is a Select R(b,j), exists z as W(a,i,e) //scan all W(a,i,e) if(y->isSelect()) { for (xStoUsersIt=xStoUsers.begin(); xStoUsersIt<xStoUsers.end(); xStoUsersIt++) { z=*xStoUsersIt; zArray=z->get1st(); zIndex=z->get2nd(); // create new term W(a,i,R(b,j)) newSto=mkStore(zArray,zIndex,y); // TODO check if term already seen in a previous assertion on the current path // deduce clauses for the new store newArrayDed(newSto); } } //Case 4 reverse: y is a term e of type element, x is a Select R(b,j), exists z as W(a,i,e) //scan all W(a,i,e) if(x->isSelect()) { for (yStoUsersIt=yStoUsers.begin(); yStoUsersIt<yStoUsers.end(); yStoUsersIt++) { z=*yStoUsersIt; zArray=z->get1st(); zIndex=z->get2nd(); // create new term W(a,i,R(b,j)) newSto=mkStore(zArray,zIndex,x); // TODO check if term already seen in a previous assertion on the current path // deduce clauses for the new store newArrayDed(newSto); } }*/ }
int main(int argc, char* argv[]) { /* Thread and thread attributes */ pthread_t client_thread; pthread_attr_t attr; int new_fd; /* listen on sock_fd, new connection on new_fd */ struct sockaddr_in my_addr; /* my address information */ struct sockaddr_in their_addr; /* connector's address information */ socklen_t sin_size; signal(SIGINT, intHandler); getWords(); getUsers(); //leaderboardLock = PTHREAD_MUTEX_INITIALIZER; /* generate the socket */ if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); } /* generate the end point */ my_addr.sin_family = AF_INET; /* host byte order */ if (argc == 2) { my_addr.sin_port = htons(atoi(argv[1])); /* short, network byte order */ } else { my_addr.sin_port = htons(DEFAULTPORT); /* short, network byte order */ } my_addr.sin_addr.s_addr = INADDR_ANY; /* auto-fill with my IP */ /* bzero(&(my_addr.sin_zero), 8); ZJL*/ /* zero the rest of the struct */ /* bind the socket to the end point */ if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) \ == -1) { perror("bind"); exit(1); } /* start listnening */ if (listen(sockfd, BACKLOG) == -1) { perror("listen"); exit(1); } printf("server starts listnening ...\n"); /* repeat: accept, send, close the connection */ /* for every accepted connection, use a sepetate process or thread to serve it */ while(keepRunning) { /* main accept() loop */ sin_size = sizeof(struct sockaddr_in); if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr, \ &sin_size)) == -1) { perror("accept"); continue; } printf("server: got connection from %s\n", \ inet_ntoa(their_addr.sin_addr)); //Create a thread to accept client pthread_attr_t attr; pthread_attr_init(&attr); pthread_create(&client_thread, &attr, handle_user, new_fd); //pthread_join(client_thread,NULL); } close(sockfd); return 0; }
EspolBoxServer::EspolBoxServer(QObject *parent) : QTcpServer(parent) { getUsers(); }
void MainWindow::initUI() { //Make sure the conf file exists if(!QFile::exists(DM_CONFIG_FILE)){ qDebug() << "Copying over the default configuration file:" << DM_CONFIG_FILE; if( !QFile::copy(DM_CONFIG_FILE+".dist", DM_CONFIG_FILE) ){ QMessageBox::warning(this,tr("Missing Config File"), QString(tr("The PCDM configuration file could not be found: %1")).arg(DM_CONFIG_FILE)+"\n\n"+tr("This application will now close")); exit(1); } } getUsers(); ui->UsersList->clear(); QString autoLogDelay = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "AUTO_LOGIN_DELAY"); if(!autoLogDelay.isEmpty()){ ui->spin_autoLogDelay->setValue(autoLogDelay.toInt()); } QString autoLogUser = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "AUTO_LOGIN_USER"); for (int i=0; i<mvUsers.size(); i++) { ui->UsersList->addItem(mvUsers[i]); if ( autoLogUser == mvUsers[i] ) ui->UsersList->setCurrentIndex(i); } QString autoLog = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "ENABLE_AUTO_LOGIN"); if ( autoLog == "TRUE" ) { ui->AutoLoginEnabledCB->setChecked(true); ui->UsersList->setEnabled(true); } else { ui->AutoLoginEnabledCB->setChecked(false); ui->UsersList->setEnabled(false); } ui->EnableVNC->setChecked(false); QString vnc = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "ALLOW_REMOTE_LOGIN"); if ( vnc == "TRUE" ) ui->EnableVNC->setChecked(true); ui->checkShowPW->setChecked(false); QString showpw = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "ENABLE_VIEW_PASSWORD_BUTTON"); if ( showpw == "TRUE" ) ui->checkShowPW->setChecked(true); ui->checkShowUsers->setChecked(true); //PCDM defaults to true QString showusers = pcbsd::Utils::getValFromSHFile(DM_CONFIG_FILE, "SHOW_SYSTEM_USERS"); if( showusers != "TRUE" ){ ui->checkShowUsers->setChecked(false); } //Update the UI appropriately itemChanged(); ui->SaveButton->setEnabled(false); //re-disable the save button because nothing has changed yet //Now setup all the signals/slots for updating the UI appropriately connect( ui->AutoLoginEnabledCB, SIGNAL(stateChanged(int)), this, SLOT(itemChanged()) ); connect( ui->UsersList, SIGNAL(currentIndexChanged(int)), this, SLOT(itemChanged()) ); connect( ui->spin_autoLogDelay, SIGNAL(valueChanged(int)), this, SLOT(itemChanged()) ); connect( ui->EnableVNC, SIGNAL(stateChanged(int)), this, SLOT(itemChanged()) ); connect( ui->checkShowPW, SIGNAL(stateChanged(int)), this, SLOT(itemChanged()) ); connect( ui->checkShowUsers, SIGNAL(stateChanged(int)), this, SLOT(itemChanged()) ); }
void MainWindow::initUI() { //Make sure the conf file exists if(!QFile::exists(DM_CONFIG_FILE)){ qDebug() << "Copying over the default configuration file:" << DM_CONFIG_FILE; if( !QFile::copy(DM_CONFIG_FILE+".dist", DM_CONFIG_FILE) ){ QMessageBox::warning(this,tr("Missing Config File"), QString(tr("The PCDM configuration file could not be found: %1")).arg(DM_CONFIG_FILE)+"\n\n"+tr("This application will now close")); exit(1); } } getUsers(); ui->UsersList->clear(); QString autoLogDelay = getValFromSHFile(DM_CONFIG_FILE, "AUTO_LOGIN_DELAY"); if(!autoLogDelay.isEmpty()){ ui->spin_autoLogDelay->setValue(autoLogDelay.toInt()); } QString autoLogUser = getValFromSHFile(DM_CONFIG_FILE, "AUTO_LOGIN_USER"); for (int i=0; i<mvUsers.size(); i++) { ui->UsersList->addItem(mvUsers[i]); if ( autoLogUser == mvUsers[i] ) ui->UsersList->setCurrentIndex(i); } QString autoLog = getValFromSHFile(DM_CONFIG_FILE, "ENABLE_AUTO_LOGIN"); if ( autoLog == "TRUE" ) { ui->AutoLoginEnabledCB->setChecked(true); ui->UsersList->setEnabled(true); } else { ui->AutoLoginEnabledCB->setChecked(false); ui->UsersList->setEnabled(false); } ui->EnableVNC->setChecked(false); QString vnc = getValFromSHFile(DM_CONFIG_FILE, "ALLOW_REMOTE_LOGIN"); if ( vnc == "TRUE" ) ui->EnableVNC->setChecked(true); ui->checkShowPW->setChecked(false); QString showpw = getValFromSHFile(DM_CONFIG_FILE, "ENABLE_VIEW_PASSWORD_BUTTON"); if ( showpw == "TRUE" ) ui->checkShowPW->setChecked(true); ui->checkShowUsers->setChecked(true); //PCDM defaults to true QString showusers = getValFromSHFile(DM_CONFIG_FILE, "SHOW_SYSTEM_USERS"); if( showusers != "TRUE" && !showusers.isEmpty() ){ ui->checkShowUsers->setChecked(false); } ui->checkAllowStealth->setChecked(false); //PCDM defaults to false QString allowstealth = getValFromSHFile(DM_CONFIG_FILE, "ALLOW_STEALTH_LOGIN"); if(allowstealth.toLower() == "true"){ ui->checkAllowStealth->setChecked(true); } ui->groupAllowUnder1K->setChecked(false); //PCDM defaults to false QString allowU1K = getValFromSHFile(DM_CONFIG_FILE, "ALLOW_UID_UNDER_1K"); if(allowU1K.toLower() == "true"){ ui->groupAllowUnder1K->setChecked(true); } //Theme setting loadAvailableThemes(); //update the combobox first QString theme = getValFromSHFile(DM_CONFIG_FILE, "THEME_FILE"); int index = ui->combo_themes->findData(theme); if(index>=0){ ui->combo_themes->setCurrentIndex(index); ui->radio_theme_bundle->setChecked(true); } else{ ui->line_theme_custom->setText(theme); ui->radio_theme_custom->setChecked(true); } //Update the UI appropriately itemChanged(); ui->SaveButton->setEnabled(false); //re-disable the save button because nothing has changed yet //Now setup all the signals/slots for updating the UI appropriately connect( ui->AutoLoginEnabledCB, SIGNAL(stateChanged(int)), this, SLOT(itemChanged()) ); connect( ui->UsersList, SIGNAL(currentIndexChanged(int)), this, SLOT(itemChanged()) ); connect( ui->spin_autoLogDelay, SIGNAL(valueChanged(int)), this, SLOT(itemChanged()) ); connect( ui->EnableVNC, SIGNAL(stateChanged(int)), this, SLOT(itemChanged()) ); connect( ui->checkShowPW, SIGNAL(stateChanged(int)), this, SLOT(itemChanged()) ); connect( ui->checkShowUsers, SIGNAL(stateChanged(int)), this, SLOT(itemChanged()) ); connect( ui->checkAllowStealth, SIGNAL(stateChanged(int)), this, SLOT(itemChanged()) ); connect( ui->groupAllowUnder1K, SIGNAL(toggled(bool)), this, SLOT(itemChanged()) ); connect( ui->radio_theme_bundle, SIGNAL(toggled(bool)), this, SLOT(itemChanged()) ); connect( ui->radio_theme_custom, SIGNAL(toggled(bool)), this, SLOT(itemChanged()) ); connect( ui->combo_themes, SIGNAL(currentIndexChanged(int)), this, SLOT(itemChanged()) ); connect( ui->line_exuser, SIGNAL(returnPressed()), this, SLOT(on_tool_exuser_add_clicked()) ); }
int main(int argc, char *argv[]) { int i, j, k, countTopUsers; //file containing matrix of form CSR char *ipCSRAdjFileName; //list of users on which to apply page rank char *usersFileName; //number of cpus int cpucount; //to store graph adjacency matrix gk_csr_t *adjMat; int numUsers; //araay of user id int *users; gk_fkv_t **topUsers; int *topUserCount; int minSimUsers; char *opFile = "GraphRead.txt"; if (argc < 4) { //not wnough arguments passed printf("\n Not enough arguments passed. \n"); return -1; } //parse commandline arguments ipCSRAdjFileName = argv[1]; usersFileName = argv[2]; minSimUsers = atoi(argv[3]); cpucount = atoi(argv[4]); //printf("\nBuilding adjacency matrix...\n"); //read the adjacency matrix adjMat = gk_csr_Read(ipCSRAdjFileName, GK_CSR_FMT_CSR, 0, 0); //gk_csr_Write(adjMat, opFile, GK_CSR_FMT_CSR, 0, 0); fprintf(stderr, "\nMatrix building completed...\n"); //get the number of users numUsers = getLineCount(usersFileName); users = getUsers(usersFileName, numUsers); //maintain storage of top similar users of cpucount users topUsers = (gk_fkv_t**) malloc(sizeof(gk_fkv_t*) * cpucount); for (i = 0; i < cpucount; i++) { topUsers[i] = (gk_fkv_t*) malloc(sizeof(gk_fkv_t) * minSimUsers); } //storage for top users count of chunk topUserCount = (int *) malloc(sizeof(int) * cpucount); //apply the personalized page rank for each user for (i = 0; i < numUsers; i+=cpucount) { #pragma omp parallel default(none) private(j) shared(users, topUsers, topUserCount, adjMat) \ firstprivate(i, minSimUsers, numUsers, cpucount) { #pragma omp for for (j = 0; j < cpucount; j++) { if (i+j < numUsers) { //find top users for users[i+j] //get the top rank vertices from personalized page rank iteration topUserCount[j] = getTopSimUsers(adjMat, users[i+j], topUsers[j], minSimUsers); } } } //write the values for users chunks for (j = 0; j < cpucount; j++) { if (i+j < numUsers) { //user printf("%d", users[i+j]); for (k = 0; k < topUserCount[j]; k ++) { //print the top similar users with corresponding pr printf("\t%d:%f", topUsers[j][k].val, topUsers[j][k].key); } printf("\n"); } } } return 0; }
/** * Load the user/passwd form mysql.user table into the service users' hashtable * environment. * * @param service The current service * @return -1 on any error or the number of users inserted (0 means no users at all) */ int load_mysql_users(SERVICE *service) { return getUsers(service, service->users); }