本文整理汇总了C++中UDSEntry类的典型用法代码示例。如果您正苦于以下问题:C++ UDSEntry类的具体用法?C++ UDSEntry怎么用?C++ UDSEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UDSEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qCDebug
void MANProtocol::stat( const QUrl& url)
{
qCDebug(KIO_MAN_LOG) << "ENTERING STAT " << url.url();
QString title, section;
if (!parseUrl(url.path(), title, section))
{
error(KIO::ERR_MALFORMED_URL, url.url());
return;
}
qCDebug(KIO_MAN_LOG) << "URL " << url.url() << " parsed to title='" << title << "' section=" << section;
UDSEntry entry;
entry.insert(KIO::UDSEntry::UDS_NAME, title);
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
#if 0 // not useful, is it?
QString newUrl = "man:"+title;
if (!section.isEmpty())
newUrl += QString("(%1)").arg(section);
entry.insert(KIO::UDSEntry::UDS_URL, newUrl);
#endif
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QString::fromLatin1("text/html"));
statEntry(entry);
finished();
}
示例2: qDebug
void LocateProtocol::stat(const QUrl& url)
{
qDebug() << "LocateProtocol::stat(" << url << ")" << endl ;
setUrl(url);
/*
* I'm tired of trying to make this work. Error out to avoid recursive call back loop.
* Dolphin doesn't handle 'help' protocol anyway.
*/
if (isHelpRequest()){
error(KIO::ERR_DOES_NOT_EXIST, QString());
return;
}
if (isSearchRequest() || isConfigRequest()) {
bool isDir = isSearchRequest() && m_locater.binaryExists();
/// TODO Are there ever '/''s in our urls after the scheme?
UDSEntry entry;
entry.insert(KIO::UDSEntry::UDS_NAME, m_url.toString(QUrl::RemoveScheme));
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, isDir ? S_IFDIR : S_IFREG);
statEntry(entry);
finished();
} else {
// What's this?
error(KIO::ERR_DOES_NOT_EXIST, QString());
}
}
示例3: changeCheck
void kio_sieveProtocol::urlStat(const QUrl &url)
{
changeCheck(url);
if (!connect()) {
return;
}
UDSEntry entry;
QString filename = url.fileName();
if (filename.isEmpty()) {
entry.insert(KIO::UDSEntry::UDS_NAME, QStringLiteral("/"));
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700);
statEntry(entry);
} else {
if (!sendData("LISTSCRIPTS")) {
return;
}
while (receiveData()) {
if (r.getType() == kio_sieveResponse::ACTION) {
if (r.getAction().toLower().count("ok") == 1) {
// Script list completed
break;
}
} else {
if (filename == QString::fromUtf8(r.getKey())) {
entry.clear();
entry.insert(KIO::UDSEntry::UDS_NAME, QString::fromUtf8(r.getKey()));
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
if (r.getExtra() == "ACTIVE") {
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0700);
} else {
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0600);
}
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/sieve"));
//setMetaData("active", (r.getExtra() == "ACTIVE") ? "yes" : "no");
statEntry(entry);
// cannot break here because we need to clear
// the rest of the incoming data.
}
}
}
}
finished();
}
示例4: url
void FtpSlave::listEntry( const UDSEntry &entry, bool ready )
{
// some parts of the KIO API look stupid...
if ( ready )
return;
bool isDir = false;
KURL url( m_currentURL );
QString name;
for ( UDSEntry::ConstIterator it = entry.begin();
it != entry.end(); ++it ) {
switch ( ( *it ).m_uds ) {
case UDS_FILE_TYPE:
isDir = S_ISDIR( ( *it ).m_long );
break;
case UDS_NAME:
name = ( *it ).m_str;
break;
default: break;
}
}
if ( isDir )
name += '/';
url.addPath( name );
sendString( QString::fromLatin1( "<a href=\"%1\">%2</a>\n" ).
arg( url.url() ).arg( name ) );
}
示例5: kdDebug
void tdeio_isoProtocol::stat( const KURL & url )
{
TQString path;
UDSEntry entry;
kdDebug() << "tdeio_isoProtocol::stat " << url.url() << endl;
if ( !checkNewFile( url.path(), path, url.hasRef() ? url.htmlRef().toInt() : -1 ) )
{
// We may be looking at a real directory - this happens
// when pressing up after being in the root of an archive
TQCString _path( TQFile::encodeName(url.path()));
kdDebug() << "tdeio_isoProtocol::stat (stat) on " << _path << endl;
struct stat buff;
if ( ::stat( _path.data(), &buff ) == -1 || !S_ISDIR( buff.st_mode ) ) {
kdDebug() << "isdir=" << S_ISDIR( buff.st_mode ) << " errno=" << strerror(errno) << endl;
error( TDEIO::ERR_DOES_NOT_EXIST, url.path() );
return;
}
// Real directory. Return just enough information for KRun to work
UDSAtom atom;
atom.m_uds = TDEIO::UDS_NAME;
atom.m_str = url.fileName();
entry.append( atom );
kdDebug() << "tdeio_isoProtocol::stat returning name=" << url.fileName() << endl;
atom.m_uds = TDEIO::UDS_FILE_TYPE;
atom.m_long = buff.st_mode & S_IFMT;
entry.append( atom );
statEntry( entry );
finished();
// And let go of the iso file - for people who want to unmount a cdrom after that
delete m_isoFile;
m_isoFile = 0L;
return;
}
const KArchiveDirectory* root = m_isoFile->directory();
const KArchiveEntry* isoEntry;
if ( path.isEmpty() )
{
path = TQString::fromLatin1( "/" );
isoEntry = root;
} else {
isoEntry = root->entry( path );
}
if ( !isoEntry )
{
error( TDEIO::ERR_DOES_NOT_EXIST, path );
return;
}
createUDSEntry( isoEntry, entry );
statEntry( entry );
finished();
}
示例6: kdDebug
//===========================================================================
void SMBSlave::stat(const KURL &kurl)
{
kdDebug(KIO_SMB) << "SMBSlave::stat on " << kurl << endl;
// make a valid URL
KURL url = checkURL(kurl);
// if URL is not valid we have to redirect to correct URL
if(url != kurl)
{
kdDebug() << "redirection " << url << endl;
redirection(url);
finished();
return;
}
m_current_url = url;
UDSAtom udsatom;
UDSEntry udsentry;
// Set name
udsatom.m_uds = KIO::UDS_NAME;
udsatom.m_str = kurl.fileName();
udsentry.append(udsatom);
switch(m_current_url.getType())
{
case SMBURLTYPE_UNKNOWN:
error(ERR_MALFORMED_URL, m_current_url.prettyURL());
finished();
return;
case SMBURLTYPE_ENTIRE_NETWORK:
case SMBURLTYPE_WORKGROUP_OR_SERVER:
udsatom.m_uds = KIO::UDS_FILE_TYPE;
udsatom.m_long = S_IFDIR;
udsentry.append(udsatom);
break;
case SMBURLTYPE_SHARE_OR_PATH:
if(browse_stat_path(m_current_url, udsentry, false))
break;
else
{
kdDebug(KIO_SMB) << "SMBSlave::stat ERROR!!" << endl;
finished();
return;
}
default:
kdDebug(KIO_SMB) << "SMBSlave::stat UNKNOWN " << url << endl;
finished();
return;
}
statEntry(udsentry);
finished();
}
示例7: addService
void ZeroConfProtocol::addService( DNSSD::RemoteService::Ptr service )
{
UDSEntry entry;
entry.insert( UDSEntry::UDS_NAME, service->serviceName() );
entry.insert( UDSEntry::UDS_ACCESS, 0666);
entry.insert( UDSEntry::UDS_FILE_TYPE, S_IFDIR );
const QString iconName = KProtocolInfo::icon( knownProtocols[service->type()].protocol );
if (!iconName.isNull())
entry.insert( UDSEntry::UDS_ICON_NAME, iconName );
listEntry( entry, false );
}
示例8: kDebug
bool AfcDevice::open( const QString& path, QIODevice::OpenMode mode, KIO::Error& error )
{
kDebug(KIO_AFC) << path << "mode: " << mode;
bool ret = false;
afc_file_mode_t file_mode = AFC_FOPEN_RDONLY;
if ( QIODevice::ReadOnly == mode )
{
file_mode = AFC_FOPEN_RDONLY;
}
else if ( QIODevice::ReadWrite == mode )
{
file_mode = AFC_FOPEN_RW;
}
else if ( QIODevice::WriteOnly == mode )
{
file_mode = AFC_FOPEN_WRONLY;
}
else if ( ( QIODevice::ReadWrite | QIODevice::Truncate ) == mode )
{
file_mode = AFC_FOPEN_WR;
}
else if ( QIODevice::Append == mode )
{
file_mode = AFC_FOPEN_APPEND;
}
else if ( QIODevice::Truncate == mode )
{
file_mode = AFC_FOPEN_RDAPPEND;
}
else
{
error = KIO::ERR_COULD_NOT_ACCEPT;
return false;
}
afc_error_t err = afc_file_open(_afc, (const char*) path.toLocal8Bit(), file_mode, &openFd);
if ( checkError(err, error) )
{
openPath = path;
UDSEntry entry;
if ( createUDSEntry("", path, entry, error) )
{
ret = true;
_proto->totalSize( entry.numberValue(UDSEntry::UDS_SIZE, 0) );
_proto->position( 0 );
}
}
return ret;
}
示例9: qCDebug
//===========================================================================
void SMBSlave::stat( const QUrl& kurl )
{
qCDebug(KIO_SMB) << kurl;
// make a valid URL
QUrl url = checkURL(kurl);
// if URL is not valid we have to redirect to correct URL
if (url != kurl)
{
qCDebug(KIO_SMB) << "redirection " << url;
redirection(url);
finished();
return;
}
m_current_url = url;
UDSEntry udsentry;
// Set name
udsentry.insert( KIO::UDSEntry::UDS_NAME, kurl.fileName() );
switch(m_current_url.getType())
{
case SMBURLTYPE_UNKNOWN:
error(ERR_MALFORMED_URL,m_current_url.toDisplayString());
return;
case SMBURLTYPE_ENTIRE_NETWORK:
case SMBURLTYPE_WORKGROUP_OR_SERVER:
udsentry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
break;
case SMBURLTYPE_SHARE_OR_PATH:
if (browse_stat_path(m_current_url, udsentry, false))
break;
else {
qCDebug(KIO_SMB) << "ERROR!!";
finished();
return;
}
default:
qCDebug(KIO_SMB) << "UNKNOWN " << url;
finished();
return;
}
statEntry(udsentry);
finished();
}
示例10: createUDSEntry
void ArchiveProtocol::createUDSEntry( const KArchiveEntry * archiveEntry, UDSEntry & entry )
{
entry.clear();
entry.insert( KIO::UDSEntry::UDS_NAME, archiveEntry->name() );
entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, archiveEntry->permissions() & S_IFMT ); // keep file type only
entry.insert( KIO::UDSEntry::UDS_SIZE, archiveEntry->isFile() ? ((KArchiveFile *)archiveEntry)->size() : 0L );
entry.insert( KIO::UDSEntry::UDS_MODIFICATION_TIME, archiveEntry->date());
entry.insert( KIO::UDSEntry::UDS_ACCESS, archiveEntry->permissions() & 07777 ); // keep permissions only
entry.insert( KIO::UDSEntry::UDS_USER, archiveEntry->user());
entry.insert( KIO::UDSEntry::UDS_GROUP, archiveEntry->group());
entry.insert( KIO::UDSEntry::UDS_LINK_DEST, archiveEntry->symLinkTarget());
}
示例11: app_file
// internal function
// fills a file item with its name and size
static void app_file(UDSEntry& e, const QString & name, size_t size)
{
e.clear();
app_entry(e, KIO::UDSEntry::UDS_NAME, name);
app_entry(e, KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
app_entry(e, KIO::UDSEntry::UDS_SIZE, size);
}
示例12: app_dir
// internal function
// fills a directory item with its name and size
static void app_dir(UDSEntry& e, const QString & name)
{
e.clear();
app_entry(e, KIO::UDSEntry::UDS_NAME, name);
app_entry(e, KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
app_entry(e, KIO::UDSEntry::UDS_SIZE, 1);
}
示例13: cache_stat
//---------------------------------------------------------------------------
bool SMBSlave::browse_stat_path(const SMBUrl& _url, UDSEntry& udsentry, bool ignore_errors)
// Returns: true on success, false on failure
{
SMBUrl url = _url;
int cacheStatErr = cache_stat(url, &st);
if(cacheStatErr == 0)
{
if(!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode))
{
qCDebug(KIO_SMB) << "mode: "<< st.st_mode;
warning(i18n("%1:\n"
"Unknown file type, neither directory or file.", url.toDisplayString()));
return false;
}
udsentry.insert(KIO::UDSEntry::UDS_FILE_TYPE, st.st_mode & S_IFMT);
udsentry.insert(KIO::UDSEntry::UDS_SIZE, st.st_size);
QString str;
uid_t uid = st.st_uid;
struct passwd *user = getpwuid( uid );
if ( user )
str = user->pw_name;
else
str = QString::number( uid );
udsentry.insert(KIO::UDSEntry::UDS_USER, str);
gid_t gid = st.st_gid;
struct group *grp = getgrgid( gid );
if ( grp )
str = grp->gr_name;
else
str = QString::number( gid );
udsentry.insert(KIO::UDSEntry::UDS_GROUP, str);
udsentry.insert(KIO::UDSEntry::UDS_ACCESS, st.st_mode & 07777);
udsentry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, st.st_mtime);
udsentry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, st.st_atime);
// No, st_ctime is not UDS_CREATION_TIME...
}
else
{
if (!ignore_errors) {
if (cacheStatErr == EPERM || cacheStatErr == EACCES)
if (checkPassword(url)) {
redirection( url );
return false;
}
reportError(url, cacheStatErr);
} else if (cacheStatErr == ENOENT || cacheStatErr == ENOTDIR) {
warning(i18n("File does not exist: %1", url.url()));
}
qCDebug(KIO_SMB) << "ERROR!!";
return false;
}
return true;
}
示例14: appendACLAtoms
static void appendACLAtoms( const QByteArray & path, UDSEntry& entry, mode_t type, bool withACL )
{
// first check for a noop
if ( acl_extended_file( path.data() ) == 0 ) return;
acl_t acl = 0;
acl_t defaultAcl = 0;
bool isDir = S_ISDIR( type );
// do we have an acl for the file, and/or a default acl for the dir, if it is one?
acl = acl_get_file( path.data(), ACL_TYPE_ACCESS );
/* Sadly libacl does not provided a means of checking for extended ACL and default
* ACL separately. Since a directory can have both, we need to check again. */
if ( isDir ) {
if ( acl ) {
if ( !FileProtocol::isExtendedACL( acl ) ) {
acl_free( acl );
acl = 0;
}
}
defaultAcl = acl_get_file( path.data(), ACL_TYPE_DEFAULT );
}
if ( acl || defaultAcl ) {
kDebug(7101) << path.constData() << "has extended ACL entries";
entry.insert( KIO::UDSEntry::UDS_EXTENDED_ACL, 1 );
}
if ( withACL ) {
if ( acl ) {
const QString str = aclToText(acl);
entry.insert( KIO::UDSEntry::UDS_ACL_STRING, str );
kDebug(7101) << path.constData() << "ACL:" << str;
}
if ( defaultAcl ) {
const QString str = aclToText(defaultAcl);
entry.insert( KIO::UDSEntry::UDS_DEFAULT_ACL_STRING, str );
kDebug(7101) << path.constData() << "DEFAULT ACL:" << str;
}
}
if ( acl ) acl_free( acl );
if ( defaultAcl ) acl_free( defaultAcl );
}
示例15: statServer
void kio_afpProtocol::statServer(void)
{
UDSEntry entry;
UDSAtom atom;
atom.m_uds = KIO::UDS_NAME;
atom.m_str = QString::null;
entry.append( atom );
atom.m_uds = KIO::UDS_FILE_TYPE;
atom.m_long = S_IFDIR;
entry.append( atom );
atom.m_uds = KIO::UDS_ACCESS;
atom.m_long = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
entry.append( atom );
atom.m_uds = KIO::UDS_USER;
atom.m_str = "root";
entry.append( atom );
atom.m_uds = KIO::UDS_GROUP;
entry.append( atom );
// no size
statEntry( entry );
}