Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

ArClientFileToClient Class Reference

This class will interact with the ArServerFileToClient and get a file on the server. More...

#include <ArClientFileUtils.h>

List of all members.

Public Member Functions

void addFileReceivedCallback (ArFunctor1< int > *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a callback for when we get the desired file (or fail).
 ArClientFileToClient (ArClientBase *client)
 Constructor.
void cancelGet (void)
 Cancels getting a file.
const char * getClientFileName (void)
 Gets the filename we'll save the gotten file in.
const char * getDirectory (void)
 Gets the directory we're getting from.
bool getFileFromDirectory (const char *directory, const char *fileName, const char *clientFileName)
 Get the file from a directory.
const char * getFileName (void)
 Gets the filename we're getting.
ArTime getLastReceived (void)
 Gets the last time we finished getting a file.
ArTime getLastRequested (void)
 Gets the last time we asked for a file.
bool isAvailable (void)
 Sees if the server supports what this class needs.
bool isWaitingForFile (void)
 If we're getting a file now.
void remFileReceivedCallback (ArFunctor1< int > *functor)
 Removes a callback for when we get the desired file (or fail).
virtual ~ArClientFileToClient ()
 Destructor.

Protected Member Functions

void callFileReceivedCallbacks (int val)
void netGetFile (ArNetPacket *packet)

Protected Attributes

ArMutex myCallbackMutex
ArClientBasemyClient
std::string myClientFileName
ArMutex myDataMutex
std::string myDirectory
FILE * myFile
std::string myFileName
std::list< ArFunctor1< int > * > myFileReceivedCallbacks
ArFunctor1C< ArClientFileToClient,
ArNetPacket * > 
myGetFileCB
bool myIsWaitingForFile
ArTime myLastReceived
ArTime myLastRequested
std::string myWholeFileName


Detailed Description

This class will interact with the ArServerFileToClient and get a file on the server.

If you want to find out what files are on the server use ArClientFileLister.

When get a file it doesn't happen right away, but when the file is received (or failes) the fileGotten callbacks will be called, 0 as the int for the callback means everything is good, positive error messages are from the server (1 == tried to go outside allowed area, 2 == no such directory, 3 == empty file name, 4 == problem reading file), negative are from this class (-1 == got directory but it wasn't what we wanted (if you wait the right one might come in, like if someone selects one dir then the other), -2 == can't open file to put result into).

Definition at line 160 of file ArClientFileUtils.h.


Constructor & Destructor Documentation

ArClientFileToClient::ArClientFileToClient ArClientBase client  ) 
 

Constructor.

Definition at line 290 of file ArClientFileUtils.cpp.

References ArClientBase::addHandler(), client, myClient, myFile, myGetFileCB, and myIsWaitingForFile.

ArClientFileToClient::~ArClientFileToClient  )  [virtual]
 

Destructor.

Definition at line 299 of file ArClientFileUtils.cpp.


Member Function Documentation

void ArClientFileToClient::addFileReceivedCallback ArFunctor1< int > *  functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a callback for when we get the desired file (or fail).

Definition at line 461 of file ArClientFileUtils.cpp.

References ArMutex::lock(), ArLog::log(), myCallbackMutex, myFileReceivedCallbacks, and ArMutex::unlock().

void ArClientFileToClient::callFileReceivedCallbacks int  val  )  [protected]
 

Definition at line 483 of file ArClientFileUtils.cpp.

References ArMutex::lock(), myCallbackMutex, myFileReceivedCallbacks, and ArMutex::unlock().

Referenced by netGetFile().

void ArClientFileToClient::cancelGet void   ) 
 

Cancels getting a file.

Definition at line 519 of file ArClientFileUtils.cpp.

const char * ArClientFileToClient::getClientFileName void   ) 
 

Gets the filename we'll save the gotten file in.

Definition at line 510 of file ArClientFileUtils.cpp.

References ArMutex::lock(), myClientFileName, myDataMutex, and ArMutex::unlock().

const char * ArClientFileToClient::getDirectory void   ) 
 

Gets the directory we're getting from.

Definition at line 492 of file ArClientFileUtils.cpp.

References ArMutex::lock(), myDataMutex, myDirectory, and ArMutex::unlock().

bool ArClientFileToClient::getFileFromDirectory const char *  directory,
const char *  fileName,
const char *  clientFileName
 

Get the file from a directory.

Definition at line 310 of file ArClientFileUtils.cpp.

References ArUtil::appendSlash(), ArUtil::fixSlashes(), isAvailable(), ArMutex::lock(), ArLog::log(), myClient, myClientFileName, myDataMutex, myDirectory, myFileName, myIsWaitingForFile, myLastRequested, myWholeFileName, ArClientBase::requestOnce(), ArTime::setToNow(), ArBasePacket::strToBuf(), ArBasePacket::uByte2ToBuf(), and ArMutex::unlock().

const char * ArClientFileToClient::getFileName void   ) 
 

Gets the filename we're getting.

Definition at line 501 of file ArClientFileUtils.cpp.

References ArMutex::lock(), myDataMutex, myFileName, and ArMutex::unlock().

ArTime ArClientFileToClient::getLastReceived void   ) 
 

Gets the last time we finished getting a file.

Definition at line 537 of file ArClientFileUtils.cpp.

References ArMutex::lock(), myDataMutex, myLastReceived, and ArMutex::unlock().

ArTime ArClientFileToClient::getLastRequested void   ) 
 

Gets the last time we asked for a file.

Definition at line 546 of file ArClientFileUtils.cpp.

References ArMutex::lock(), myDataMutex, myLastRequested, and ArMutex::unlock().

bool ArClientFileToClient::isAvailable void   ) 
 

Sees if the server supports what this class needs.

Definition at line 304 of file ArClientFileUtils.cpp.

References ArClientBase::dataExists(), and myClient.

Referenced by getFileFromDirectory().

bool ArClientFileToClient::isWaitingForFile void   ) 
 

If we're getting a file now.

Definition at line 528 of file ArClientFileUtils.cpp.

References ArMutex::lock(), myDataMutex, myIsWaitingForFile, and ArMutex::unlock().

void ArClientFileToClient::netGetFile ArNetPacket packet  )  [protected]
 

Definition at line 385 of file ArClientFileUtils.cpp.

References callFileReceivedCallbacks(), ArUtil::fixSlashes(), ArMutex::lock(), ArLog::log(), myClientFileName, myDataMutex, myFile, myFileName, myIsWaitingForFile, myLastReceived, myWholeFileName, ArTime::setToNow(), and ArMutex::unlock().

void ArClientFileToClient::remFileReceivedCallback ArFunctor1< int > *  functor  ) 
 

Removes a callback for when we get the desired file (or fail).

Definition at line 475 of file ArClientFileUtils.cpp.

References ArMutex::lock(), myCallbackMutex, myFileReceivedCallbacks, and ArMutex::unlock().


Member Data Documentation

ArMutex ArClientFileToClient::myCallbackMutex [protected]
 

Definition at line 196 of file ArClientFileUtils.h.

Referenced by addFileReceivedCallback(), callFileReceivedCallbacks(), and remFileReceivedCallback().

ArClientBase* ArClientFileToClient::myClient [protected]
 

Definition at line 197 of file ArClientFileUtils.h.

Referenced by ArClientFileToClient(), getFileFromDirectory(), and isAvailable().

std::string ArClientFileToClient::myClientFileName [protected]
 

Definition at line 202 of file ArClientFileUtils.h.

Referenced by getClientFileName(), getFileFromDirectory(), and netGetFile().

ArMutex ArClientFileToClient::myDataMutex [protected]
 

Definition at line 195 of file ArClientFileUtils.h.

Referenced by getClientFileName(), getDirectory(), getFileFromDirectory(), getFileName(), getLastReceived(), getLastRequested(), isWaitingForFile(), and netGetFile().

std::string ArClientFileToClient::myDirectory [protected]
 

Definition at line 199 of file ArClientFileUtils.h.

Referenced by getDirectory(), and getFileFromDirectory().

FILE* ArClientFileToClient::myFile [protected]
 

Definition at line 203 of file ArClientFileUtils.h.

Referenced by ArClientFileToClient(), and netGetFile().

std::string ArClientFileToClient::myFileName [protected]
 

Definition at line 200 of file ArClientFileUtils.h.

Referenced by getFileFromDirectory(), getFileName(), and netGetFile().

std::list<ArFunctor1<int> *> ArClientFileToClient::myFileReceivedCallbacks [protected]
 

Definition at line 206 of file ArClientFileUtils.h.

Referenced by addFileReceivedCallback(), callFileReceivedCallbacks(), and remFileReceivedCallback().

ArFunctor1C<ArClientFileToClient, ArNetPacket *> ArClientFileToClient::myGetFileCB [protected]
 

Definition at line 207 of file ArClientFileUtils.h.

Referenced by ArClientFileToClient().

bool ArClientFileToClient::myIsWaitingForFile [protected]
 

Definition at line 198 of file ArClientFileUtils.h.

Referenced by ArClientFileToClient(), getFileFromDirectory(), isWaitingForFile(), and netGetFile().

ArTime ArClientFileToClient::myLastReceived [protected]
 

Definition at line 205 of file ArClientFileUtils.h.

Referenced by getLastReceived(), and netGetFile().

ArTime ArClientFileToClient::myLastRequested [protected]
 

Definition at line 204 of file ArClientFileUtils.h.

Referenced by getFileFromDirectory(), and getLastRequested().

std::string ArClientFileToClient::myWholeFileName [protected]
 

Definition at line 201 of file ArClientFileUtils.h.

Referenced by getFileFromDirectory(), and netGetFile().


The documentation for this class was generated from the following files:
Generated on Tue Feb 20 10:51:51 2007 for ArNetworking by  doxygen 1.4.0