31 , _exportRoot(exportRoot)
45 QMap<QString, QList<VFS_tcp_export_request *> >::iterator it =
_queuedRequests.begin();
48 QList<VFS_tcp_export_request *> l = it.value();
68 #ifdef COMPRESS_TCP_MOUNT
69 message = qUncompress(message);
70 if (message.length() == 0)
71 VFS::ERROR(
"(1) Uncompressed message size was 0.");
75 printf(
"%s received: %s\n",qUtf8Printable(
className()),qUtf8Printable(message));
86 VFS::ERROR( QString(
"Can't satisfy %1 request without sender or valid json message.").arg(
className()) );
111 QString
id = r->
_metadata[
"sessionid"].toString();
113 if (r->
_data.isNull())
114 printf(
"Received invalid session information. FIXME: remove the request and abort.");
116 QJsonObject data = r->
_data.object();
122 for(
int i=0; i<queue.count(); ++i )
123 queue[i]->_session = s;
126 for(
int i=0; i<queue.count(); ++i )
156 r->
_data.setObject(o);
172 QMetaObject::invokeMethod(c->
_origin,
"executeRequest",Qt::AutoConnection,Q_ARG(
VFS_request*, c));
257 if (r->
_path.endsWith(
"__ACL__"))
261 for (
int i=0;i<l.length();i++)
279 r->
_data.setObject(o);
319 VFS::ERROR( QString(
"Could not find _sourcePathMap reference for 0x%1 (%2). Not applying diff for '%3'").arg((quintptr)source, QT_POINTER_SIZE * 2, 16, QChar(
'0')).arg(source->className()).arg(t->
_originPath), 0, t->
_user );
320 printf(
"BAD DIFF: %s\n",qUtf8Printable(t->
toJson(0,
true,
true)));
328 printf(
"%s sends: %s\n",qUtf8Printable(
className()),qUtf8Printable(
diff));
331 #ifdef COMPRESS_TCP_MOUNT
428 t->
_data = QJsonDocument();
462 QMutexLocker l(&
_lock);
476 if (!path.startsWith(
"__ACL__"))
477 VFS::WARN( QString(
"Not duplicating path %1 in pathMap. Attempted: '%2', existing: '%3'").arg((quintptr)source).arg(path).arg(
_sourcePathMap[source]) );
489 QMutexLocker l(&
_lock);
500 VFS::WARN( QString(
"Could not remove null sender %1 from sourcePathMap.").arg((quintptr)sender()) );
519 r->
_data.setObject(o);
540 , _exportRoot(exportRoot)
541 , _pendingSession(false)
567 _id =
static_cast<postID>(json[
"id"].toInt());
572 if (json.contains(
"session"))
577 QString session = json[
"session"].toString();
590 VFS::WARN(
"Can't queue request on non-VFS_tcp_export_client!");
606 QJsonDocument d = QJsonDocument::fromJson( message );
644 if (includeInitialPath)
653 if (!
_data.isEmpty())
654 o[
"data"] =
_data.object();
657 o[
"rawdata"] = QJsonValue::fromVariant(
_rawData.toBase64() );
727 printf(
"VFS_tcp_export_request sends: %s\n",qUtf8Printable(response));
730 #ifdef COMPRESS_TCP_MOUNT
731 response = qCompress(response);
#define POST_ID_CODE_DIRECTORY
#define POST_ID_SESSION_DATA
static bool checkAllowAccess(VFS_session *s, QString path, QString feature="")
Check if a session has access to a resource.
static QStringList fetchACLPaths()
Fetch the VFS path to each registered ACL file.
static QJsonObject codeDirectory(QString &error)
Gather and return a directory of code namespaces served by this VFS instance.
static VFS_request * code(VFS_request *r)
Resolve a request for code.
VFS_node is the base class from which all other VFS_node classes derive.
virtual void issueRequest(VFS_request *t)
A convenience function.
void unmounted(VFS_node *self)
Emitted when a node is unmount()ed.
void diff(VFS_node *origin, VFS_request *t)
Emit a diff, which will trigger notifySubscribers() for a mounted node.
QString className()
Return the class name of a node.
QMutex _lock
A recursive mutex that is local to this node.
virtual void applyDiff(VFS_request *r)
Apply a diff received via subscription.
virtual void receiveResponse(VFS_request *t)
Once a VFS_request has been completed, a response will be issued back to its _origin.
The base class for all requests between nodes.
static const char * requestTypeStrings[]
A printable string for each request type.
@ read
read full contents (4)
@ unsubscribe
unsubscribe from a path (10)
@ metadata
read metadata (6)
@ write
write full contents (5)
@ code
request code from a node (15)
@ codeDirectory
request a listing of code served by a node (16)
@ subscribe
subscribe to a path (9)
VFS_node * _responder
the receiver of the request
VFS_node * _origin
the origin of the request
QByteArray _rawData
the request payload, but raw data
bool hasCallback()
Check if this request has a callback set.
requestType _requestType
the action this request is performing or requesting
QString _initialPath
the target path when the request was made (relative to the responder)
QStringList _prefixPath
the prefix elements found while searching for the target
QString _user
who initiated this request, mostly for logging
virtual void fromJsonObject(QJsonObject json, bool includeInitialPath=false)
Deserialize a JSON string into a VFS_request.
virtual void execute()
after a request has completed, a request may have a special execute function.
VFS_session * _session
The session associated with this request. This is an optional value, and care should be taken to chec...
QString _reason
if something (probably bad) happened, this is the reason
QString _path
the target path remnant... the remaining path element once the request has found its target
QString _originPath
the subpath of the origin node
bool _success
if the request was successfully completed
QJsonDocument _data
the request payload
virtual QByteArray toJson(postID id=0, bool ignoreSuccess=false, bool includeInitialPath=false)
Serialize this request.
QJsonObject _metadata
the request payload
The VFS_session object represents a single session.
void error(QAbstractSocket::SocketError)
Emitted when a socket error occurs.
void connected()
Emitted when a connection has been made.
void readyMessage(QByteArray message)
Emitted when a message is ready for processing.
virtual void writeMessage(QByteArray data)
DOCME.
The socket client created by VFS_tcp_export.
QByteArray _icon
An icon that can override the icon provided by the shared node.
QMap< QString, QList< VFS_tcp_export_request * > > _queuedRequests
The requests that have been queued, per session id, due to a session definition request.
virtual void applyDiff(VFS_request *t)
virtual void receiveMessage(QByteArray message)
virtual ~VFS_tcp_export_client()
virtual void receiveResponse(VFS_request *t)
VFS_tcp_export_client(QTcpSocket *socket, QString exportRoot, bool ssl=false, QSslConfiguration sslConfiguration=QSslConfiguration(), QByteArray icon="")
virtual void removeSourcePathMap(VFS_node *n)
Remove a _sourcePathMap entry, if found.
virtual void addSourcePathMap(VFS_node *source, QString path)
Add a VFS_tcp_export_client::_sourcePathMap entry for a path from a client's perspective to a VFS_nod...
virtual void sendCodeDirectory()
DOCME.
QMap< VFS_node *, QString > _sourcePathMap
Map between nodes and subscription paths.
friend class VFS_tcp_export_request
QString _exportRoot
The VFS path to export.
virtual void executeMessageRequest(VFS_tcp_export_request *r)
Execute a message request.
The VFS_tcp_export class needs path information to translate between mounted VFS instances.
virtual VFS_request * createDiff(VFS_node *origin, QString originPath)
VFS_tcp_export_request::createDiff.
bool _pendingSession
This request is pending a session definition.
virtual QByteArray toJson(postID id=0, bool ignoreSuccess=false, bool includeInitialPath=false)
Serialize this request.
static VFS_tcp_export_request * fromMessage(QByteArray message, QString exportRoot, VFS_tcp_client *origin)
postID _id
The ID of this request.
virtual void fromJsonObject(QJsonObject json, bool includeInitialPath=false)
Deserialize a JSON string into a VFS_request.
QString _exportRoot
The VFS node being exported.
virtual ~VFS_tcp_export_request()
VFS_tcp_export_request(VFS_tcp_client *origin, QString exportRoot)
virtual void execute()
DOCME.
static bool registerSession(QString id, VFS_session *session)
Register a session with the session registry.
static VFS_session * fetchSession(QString id)
Fetch a session by id.
static bool requestSession(QString id, VFS_tcp_export_client *client)
Request a session by id from a given VFS_tcp_export_client.
static VFS * root()
Return the root node of the VFS filesystem.
static void LOG(QString message, int level=0, QString user="server")
Send a message to the VFS::_messages VFS_stream.
static void ERROR(QString message, int level=0, QString user="server")
Send a message to the VFS::_errors VFS_stream.
static void WARN(QString message, int level=0, QString user="server")
Send a message to the VFS::_warnings VFS_stream.
message(m)
Change the message of an existing arrowMessage.
getter path
a getter DOCME
QString cleanPath(QString path)
Clean and normalize a VFS path.