add read users list
This commit is contained in:
		
							parent
							
								
									1fb645b003
								
							
						
					
					
						commit
						0b1bb18f83
					
				
							
								
								
									
										23
									
								
								.qmake.stash
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								.qmake.stash
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | |||||||
|  | QMAKE_CXX.QT_COMPILER_STDCXX = 201402L | ||||||
|  | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 9 | ||||||
|  | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 | ||||||
|  | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 | ||||||
|  | QMAKE_CXX.COMPILER_MACROS = \ | ||||||
|  |     QT_COMPILER_STDCXX \ | ||||||
|  |     QMAKE_GCC_MAJOR_VERSION \ | ||||||
|  |     QMAKE_GCC_MINOR_VERSION \ | ||||||
|  |     QMAKE_GCC_PATCH_VERSION | ||||||
|  | QMAKE_CXX.INCDIRS = \ | ||||||
|  |     /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9 \ | ||||||
|  |     /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9/x86_64-pc-linux-gnu \ | ||||||
|  |     /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include/g++-v9/backward \ | ||||||
|  |     /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include \ | ||||||
|  |     /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include-fixed \ | ||||||
|  |     /usr/include | ||||||
|  | QMAKE_CXX.LIBDIRS = \ | ||||||
|  |     /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0 \ | ||||||
|  |     /usr/lib64 \ | ||||||
|  |     /lib64 \ | ||||||
|  |     /usr/x86_64-pc-linux-gnu/lib \ | ||||||
|  |     /usr/lib \ | ||||||
|  |     /lib | ||||||
| @ -1,6 +1,6 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <!DOCTYPE QtCreatorProject> | <!DOCTYPE QtCreatorProject> | ||||||
| <!-- Written by QtCreator 4.8.2, 2020-05-19T00:02:05. --> | <!-- Written by QtCreator 4.8.2, 2020-05-20T00:08:38. --> | ||||||
| <qtcreator> | <qtcreator> | ||||||
|  <data> |  <data> | ||||||
|   <variable>EnvironmentId</variable> |   <variable>EnvironmentId</variable> | ||||||
|  | |||||||
| @ -10,6 +10,7 @@ public: | |||||||
|   data_acces(); |   data_acces(); | ||||||
|   virtual std::string get_passwd(std::string username) = 0; |   virtual std::string get_passwd(std::string username) = 0; | ||||||
|   virtual std::list<std::string> get_pinfo()=0; |   virtual std::list<std::string> get_pinfo()=0; | ||||||
|  |   virtual std::list<std::string> get_uinfo()=0; | ||||||
|   virtual void write_install(std::string package, std::string user)=0; |   virtual void write_install(std::string package, std::string user)=0; | ||||||
|   virtual void write_remove(std::string)=0; |   virtual void write_remove(std::string)=0; | ||||||
|   virtual bool get_package_exists(std::string package)=0; |   virtual bool get_package_exists(std::string package)=0; | ||||||
|  | |||||||
| @ -43,6 +43,27 @@ std::list<std::string> msql_acces::get_pinfo(){ | |||||||
|   return ret; |   return ret; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::list<std::string> msql_acces::get_uinfo(){ | ||||||
|  |   sql::PreparedStatement *pstmt = | ||||||
|  |       con->prepareStatement("select username,admin from users"); | ||||||
|  |   sql::ResultSet *res = pstmt->executeQuery(); | ||||||
|  |   std::list<std::string> ret; | ||||||
|  |   std::string aux; | ||||||
|  |   while(res->next()){ | ||||||
|  |       aux=""; | ||||||
|  |       aux += res->getString(1); | ||||||
|  |       //aux += ":"+res->getString(2);
 | ||||||
|  |       if(res->getBoolean(2)){ | ||||||
|  |           aux+=":t"; | ||||||
|  |         }else{ | ||||||
|  |           aux+=":f"; | ||||||
|  |         } | ||||||
|  |       ret.push_back(aux); | ||||||
|  |     } | ||||||
|  |   delete res; | ||||||
|  |   return ret; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void msql_acces::write_install(std::string package, std::string user){ | void msql_acces::write_install(std::string package, std::string user){ | ||||||
|   sql::PreparedStatement *pstmt = |   sql::PreparedStatement *pstmt = | ||||||
|       con->prepareStatement("insert into packages(name,user) values(?,(select id from users where username=?))"); |       con->prepareStatement("insert into packages(name,user) values(?,(select id from users where username=?))"); | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ public: | |||||||
|   msql_acces(); |   msql_acces(); | ||||||
|   std::string get_passwd(std::string username); |   std::string get_passwd(std::string username); | ||||||
|   std::list<std::string> get_pinfo(); |   std::list<std::string> get_pinfo(); | ||||||
|  |   std::list<std::string> get_uinfo(); | ||||||
|   void write_install(std::string package, std::string user); |   void write_install(std::string package, std::string user); | ||||||
|   void write_remove(std::string); |   void write_remove(std::string); | ||||||
|   bool get_package_exists(std::string package); |   bool get_package_exists(std::string package); | ||||||
|  | |||||||
| @ -38,7 +38,9 @@ void session_manager::start_dialog(){ | |||||||
|           this->send_information(); |           this->send_information(); | ||||||
|         }else if(strcmp(buffer, "remv")==0){ |         }else if(strcmp(buffer, "remv")==0){ | ||||||
|           this->remove(); |           this->remove(); | ||||||
|         }else if(strcmp(buffer,"exit")){ |         }else if(strcmp(buffer,"uinf")==0){ | ||||||
|  |           this->send_user_info(); | ||||||
|  |         }else if(strcmp(buffer,"exit")==0){ | ||||||
|           break; |           break; | ||||||
|         } |         } | ||||||
|   } |   } | ||||||
| @ -119,6 +121,14 @@ void session_manager::send_information(){ | |||||||
|   this->write_data("end:info"); |   this->write_data("end:info"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void session_manager::send_user_info(){ | ||||||
|  |   std::list<std::string> lis=this->data->get_uinfo(); | ||||||
|  |   for(std::string info : lis){ | ||||||
|  |       this->write_data(info); | ||||||
|  |     } | ||||||
|  |   this->write_data("end:info"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| int session_manager::read_data(char* input, int size){ | int session_manager::read_data(char* input, int size){ | ||||||
|   return read(this->fd, input, size); |   return read(this->fd, input, size); | ||||||
| } | } | ||||||
|  | |||||||
| @ -10,6 +10,7 @@ public: | |||||||
|   int execute(); |   int execute(); | ||||||
|   int remove(); |   int remove(); | ||||||
|   void send_information(); |   void send_information(); | ||||||
|  |   void send_user_info(); | ||||||
|   bool validate_pass(); |   bool validate_pass(); | ||||||
|  private: |  private: | ||||||
|   std::string appli_command(char comand[], char* n_package); |   std::string appli_command(char comand[], char* n_package); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user