Remoto - VFS: VFS_tcp_mount_directory.cpp Source File
Remoto - VFS
VFS_tcp_mount_directory.cpp
Go to the documentation of this file.
1 
2 #include "VFS.h"
4 #include "VFS_tcp_mount.h"
5 #include "VFS_creator.h"
6 
19 : VFS_node_interface(mount)
20 {
21 }
22 
29 {
30  return QStringList();
31 }
32 
41 VFS_node *VFS_tcp_mount_directory::create(QString type, QVariantMap env, QDomElement child)
42 {
43  Q_UNUSED(type)
44  Q_UNUSED(env)
45  Q_UNUSED(child)
46 
47  return nullptr;
48 }
49 
50 
57 {
58  // Request a lock here so we know that all entries will be completed by this
59  // call before another node tries to register its directory.
60  QMutexLocker l(&VFS_creator::_pluginsLock);
61 
62  bool ok=false;
63  QJsonObject::iterator it = d.begin();
64  while (it != d.end())
65  {
66  if (!_directory.contains(it.key()))
67  {
68  ok = VFS_creator::registerPlugin(it.key(),this);
69  if (!ok)
70  { //VFS::WARN( QString("Could not register code for '%1' (1). Skipping.").arg(it.key()),0,className());
71  }
72  else
73  { VFS::LOG( QString("Registered code for '%1'.").arg(it.key()),9,_remoteNode->className());
74  _directory[it.key()] = true;
75  }
76  }
77  else
78  VFS::WARN( QString("Could not register code for '%1' (2). Skipping.").arg(it.key()),0,_remoteNode->className());
79 
80  it++;
81  }
82 
83  // emit that the registry has been changed to notify other nodes
84  // that they need to re-export the directory to any other upstream mounts
86 }
87 
88 
94 {
95  bool ok=false;
96  QString k;
97  QStringList keys = _directory.keys();
98  while (keys.length())
99  {
100  k = keys.takeFirst();
102  if (!ok)
103  { VFS::WARN( QString("Could not unregister code for '%1'.").arg(k),0,_remoteNode->className());
104  }
105  else
106  { _directory.remove(k);
107  VFS::LOG( QString("Unregistered code for '%1'.").arg(k),9,_remoteNode->className());
108  }
109  }
110 }
static bool registerPlugin(QString name, VFS_node_interface *node)
Register a plugin.
static bool unregisterPlugin(QString name)
Unregister a plugin.
static QMutex _pluginsLock
A mutex for protecting the _plugins object.
Definition: VFS_creator.h:41
The interface class for dynamically loaded plugins.
VFS_node * _remoteNode
The node responding to requests for remote resources.
VFS_node is the base class from which all other VFS_node classes derive.
Definition: VFS_node.h:143
QString className()
Return the class name of a node.
Definition: VFS_node.cpp:2039
virtual VFS_node * create(QString type, QVariantMap env, QDomElement child)
This node create()s nothing, it is used for code registration purposes.
virtual void registerDirectory(QJsonObject d)
Register entries to the code directory.
virtual QStringList provides()
This node provide()s nothing, it is used for code registration purposes.
QJsonObject _directory
The directory of code registered to this node.
VFS_tcp_mount_directory(VFS_tcp_mount *mount)
VFS_tcp_mount_directory constructor.
virtual void unregisterDirectory()
Unregister all entries in this directory.
The VFS_tcp_mount class is a client side connection that will attempt to connect to another VFS insta...
Definition: VFS_tcp_mount.h:13
static VFS * root()
Return the root node of the VFS filesystem.
Definition: VFS.cpp:399
static void LOG(QString message, int level=0, QString user="server")
Send a message to the VFS::_messages VFS_stream.
Definition: VFS.cpp:209
void codeDirectoryUpdated()
Emitted when VFS_creator has had its _plugins updated. This is for VFS_tcp_mount and VFS_tcp_export.
static void WARN(QString message, int level=0, QString user="server")
Send a message to the VFS::_warnings VFS_stream.
Definition: VFS.cpp:258
setter type
a setter DOCME