Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
accountsxml.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */
16 
17 /*
18  * Account Managment - Network Client Account Managment - written by Stephane Vaxelaire <svax@free.fr>
19  */
20 
21 #ifndef __ACCOUNTS_H
22 #define __ACCOUNTS_H
23 
24 #include <iostream>
25 #include <string>
26 #include <vector>
27 #include <stdio.h>
28 #include "const.h"
29 #include <assert.h>
31 
32 using std::cout;
33 using std::endl;
34 using std::string;
35 using std::vector;
36 
37 class Account
38 {
39  ObjSerial serial;
40  char haschar;
41 //int indicates retry count
42  int isconnected;
43 
44  SOCKETALT server_sock;
45 
46 public:
48  {
52  }
53  type;
54  FILE *fp;
55  string callsign;
56  string passwd;
57  string serverip;
58  string serverport;
59 
60 //Assume player has created ship/char -> to remove in the future
62  {
63  haschar = 1;
64  isconnected = 0;
65  }
66  Account( char *scallsign, char *spasswd )
67  {
68  callsign = string( scallsign );
69  passwd = string( spasswd );
70  }
71  Account( string scallsign, string spasswd )
72  {
73  callsign = scallsign;
74  passwd = spasswd;
75  }
76 
77  void display();
78  short isNew()
79  {
80  return !haschar;
81  }
82  void setIsNew( int new1 )
83  {
84  haschar = new1;
85  }
86 
88  {
89  return this->serial;
90  }
91  void setSerial( ObjSerial sernum )
92  {
93  this->serial = sernum;
94  }
96  {
97  return this->server_sock;
98  }
99  void setSocket( SOCKETALT sck )
100  {
101  this->server_sock = sck;
102  }
103  void set( char *scallsign, char *spasswd )
104  {
105  callsign = string( scallsign );
106  passwd = string( spasswd );
107  }
108  void set( string scallsign, string spasswd )
109  {
110  callsign = scallsign;
111  passwd = spasswd;
112  }
113 
114  int compareName( char *str )
115  {
116  return callsign != string( str );
117  }
118  int comparePass( char *str )
119  {
120  return passwd != string( str );
121  }
122 
123  int compareName( string str )
124  {
125  return callsign != str;
126  }
127  int comparePass( string str )
128  {
129  return passwd != str;
130  }
131  bool isConnected()
132  {
133  return isconnected != 0;
134  }
136  {
137  return isconnected;
138  }
139  void setConnected( bool mode )
140  {
141  isconnected = mode ? 1 : 0;
142  }
144  {
145  if (isconnected) isconnected++;
146  }
147 };
148 Account * getAcctNoReload( const string &key );
149 Account * getAcctTemplate( const string &key );
150 vector< Account* >getAllAccounts();
151 void LoadAccounts( const char *filename );
154 void addAcct( std::string key, Account* );
155 #endif
156