Renamed callback operations.

This commit is contained in:
lotodore
2007-02-18 01:39:06 +00:00
parent ca6adbb295
commit e6c6fa0eee
2 changed files with 13 additions and 13 deletions
+3 -3
View File
@@ -16,7 +16,7 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/* Network client thread. */
/* Callback interface for network client gui. */
#ifndef _CLIENTCALLBACK_H_
#define _CLIENTCALLBACK_H_
@@ -26,8 +26,8 @@ class ClientCallback
public:
virtual ~ClientCallback();
virtual void SignalSuccess(int actionID) = 0;
virtual void SignalError(int errorID, int osErrorID) = 0;
virtual void SignalNetClientSuccess(int actionID) = 0;
virtual void SignalNetClientError(int errorID, int osErrorID) = 0;
};
#endif
+10 -10
View File
@@ -57,20 +57,20 @@ ClientStateInit::Process(ClientThread &client, ClientCallback &cb)
if (data.serverAddr.empty())
{
cb.SignalError(ERR_SOCK_SERVERADDR_NOT_SET, 0);
cb.SignalNetClientError(ERR_SOCK_SERVERADDR_NOT_SET, 0);
throw runtime_error("ClientStateInit"); // TODO: own exception
}
if (data.serverPort < 1024)
{
cb.SignalError(ERR_SOCK_INVALID_PORT, 0);
cb.SignalNetClientError(ERR_SOCK_INVALID_PORT, 0);
throw runtime_error("ClientStateInit");
}
data.sockfd = socket(data.addrFamily, SOCK_STREAM, 0);
if (!IS_VALID_SOCKET(data.sockfd))
{
cb.SignalError(ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
cb.SignalNetClientError(ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
throw runtime_error("ClientStateInit");
}
@@ -78,12 +78,12 @@ ClientStateInit::Process(ClientThread &client, ClientCallback &cb)
unsigned long mode = 1;
if (IOCTLSOCKET(data.sockfd, FIONBIO, &mode) == SOCKET_ERROR)
{
cb.SignalError(ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
cb.SignalNetClientError(ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
throw runtime_error("ClientStateInit");
}
#endif
cb.SignalSuccess(MSG_SOCK_INIT_DONE);
cb.SignalNetClientSuccess(MSG_SOCK_INIT_DONE);
client.SetState(ClientStateResolve::Instance());
}
@@ -117,7 +117,7 @@ ClientStateResolve::Process(ClientThread &client, ClientCallback &cb)
// Set the port.
if (!socket_set_port(data.serverPort, data.addrFamily, (struct sockaddr *)&data.clientAddr, data.GetServerAddrSize()))
{
cb.SignalError(ERR_SOCK_SET_PORT_FAILED, 0);
cb.SignalNetClientError(ERR_SOCK_SET_PORT_FAILED, 0);
throw runtime_error("ClientStateResolve");
}
}
@@ -128,11 +128,11 @@ ClientStateResolve::Process(ClientThread &client, ClientCallback &cb)
tmpStr << data.serverPort;
if (!socket_resolve(data.serverAddr.c_str(), tmpStr.str().c_str(), data.addrFamily, SOCK_STREAM, 0, (struct sockaddr *)&data.clientAddr, data.GetServerAddrSize()))
{
cb.SignalError(ERR_SOCK_RESOLVE_FAILED, 0); // TODO: use errno value
cb.SignalNetClientError(ERR_SOCK_RESOLVE_FAILED, 0); // TODO: use errno value
throw runtime_error("ClientStateResolve");
}
}
cb.SignalSuccess(MSG_SOCK_RESOLVE_DONE);
cb.SignalNetClientSuccess(MSG_SOCK_RESOLVE_DONE);
client.SetState(ClientStateConnect::Instance());
}
@@ -160,10 +160,10 @@ ClientStateConnect::Process(ClientThread &client, ClientCallback &cb)
if (!IS_VALID_CONNECT(connect(data.sockfd, (struct sockaddr *)&data.clientAddr, data.GetServerAddrSize())))
{
cb.SignalError(ERR_SOCK_CONNECT_FAILED, SOCKET_ERRNO());
cb.SignalNetClientError(ERR_SOCK_CONNECT_FAILED, SOCKET_ERRNO());
throw runtime_error("ClientStateResolve");
}
cb.SignalSuccess(MSG_SOCK_RESOLVE_DONE);
cb.SignalNetClientSuccess(MSG_SOCK_RESOLVE_DONE);
client.SetState(ClientStateFinal::Instance());
}