本文整理汇总了C++中UDSEntry::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ UDSEntry::insert方法的具体用法?C++ UDSEntry::insert怎么用?C++ UDSEntry::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UDSEntry
的用法示例。
在下文中一共展示了UDSEntry::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stat
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());
}
}
示例2: createUDSEntry
void BupSlave::createUDSEntry(Node *pNode, UDSEntry &pUDSEntry, int pDetails) {
pUDSEntry.clear();
pUDSEntry.insert(KIO::UDSEntry::UDS_NAME, pNode->objectName());
if(!pNode->mSymlinkTarget.isEmpty()) {
pUDSEntry.insert(KIO::UDSEntry::UDS_LINK_DEST, pNode->mSymlinkTarget);
if(pDetails > 1) {
Node *lNode = qobject_cast<Node *>(pNode->parent())->resolve(pNode->mSymlinkTarget, true);
if(lNode != NULL) { // follow symlink only if details > 1 and it leads to something
pNode = lNode;
}
}
}
pUDSEntry.insert(KIO::UDSEntry::UDS_FILE_TYPE, pNode->mMode & S_IFMT);
pUDSEntry.insert(KIO::UDSEntry::UDS_ACCESS, pNode->mMode & 07777);
if(pDetails > 0) {
qint64 lSize = 0;
File *lFile = qobject_cast<File *>(pNode);
if(lFile != NULL) {
lSize = lFile->size();
}
pUDSEntry.insert(KIO::UDSEntry::UDS_SIZE, lSize);
pUDSEntry.insert(KIO::UDSEntry::UDS_MIME_TYPE, pNode->mMimeType);
pUDSEntry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, pNode->mAtime);
pUDSEntry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, pNode->mMtime);
pUDSEntry.insert(KIO::UDSEntry::UDS_USER, getUserName(pNode->mUid));
pUDSEntry.insert(KIO::UDSEntry::UDS_GROUP, getGroupName(pNode->mGid));
}
}
示例3:
void LDAPProtocol::LDAPEntry2UDSEntry( const LdapDN &dn, UDSEntry &entry,
const LdapUrl &usrc, bool dir )
{
int pos;
entry.clear();
QString name = dn.toString();
if ( (pos = name.indexOf(',')) > 0 )
name = name.left( pos );
if ( (pos = name.indexOf('=')) > 0 )
name.remove( 0, pos+1 );
name.replace(' ', "_");
if ( !dir ) name += ".ldif";
entry.insert( KIO::UDSEntry::UDS_NAME, name );
// the file type
entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, dir ? S_IFDIR : S_IFREG );
// the mimetype
if (!dir) {
entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, QString::fromLatin1("text/plain") );
}
entry.insert( KIO::UDSEntry::UDS_ACCESS, dir ? 0500 : 0400 );
// the url
LdapUrl url=usrc;
url.setPath('/'+dn.toString());
url.setScope( dir ? LdapUrl::One : LdapUrl::Base );
entry.insert( KIO::UDSEntry::UDS_URL, url.prettyUrl() );
}
示例4: stat
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();
}
示例5: 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 );
}
示例6: urlStat
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();
}
示例7: stat
//===========================================================================
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();
}
示例8: browse_stat_path
//---------------------------------------------------------------------------
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;
}
示例9: listDir
void kio_sieveProtocol::listDir(const QUrl &url)
{
changeCheck(url);
if (!connect()) {
return;
}
if (!sendData("LISTSCRIPTS")) {
return;
}
UDSEntry entry;
while (receiveData()) {
if (r.getType() == kio_sieveResponse::ACTION) {
if (r.getAction().toLower().count("ok") == 1) {
// Script list completed.
break;
}
} else {
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);// mark exec'able
} else {
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0600);
}
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/sieve"));
//asetMetaData("active", (r.getExtra() == "ACTIVE") ? "true" : "false");
ksDebug << "Listing script " << r.getKey() << endl;
listEntry(entry);
}
}
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: 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 );
}
示例12: createRootUDSEntry
bool AfcDevice::createRootUDSEntry( UDSEntry & entry )
{
entry.insert( UDSEntry::UDS_NAME, _id );
entry.insert( UDSEntry::UDS_DISPLAY_NAME, _name );
entry.insert( UDSEntry::UDS_ICON_NAME, _icon );
entry.insert( UDSEntry::UDS_USER, AfcProtocol::m_user );
entry.insert( UDSEntry::UDS_GROUP, AfcProtocol::m_group );
entry.insert( UDSEntry::UDS_ACCESS, 0755 );
return true;
}
示例13: stat
void InfinityProtocol::stat(const KUrl& url)
{
kDebug() << "STAT " << url.url();
if ( url.path().isEmpty() ) {
KUrl newUrl(url);
newUrl.setPath("/");
redirection(newUrl);
finished();
return;
}
if ( ! doConnect(Peer(url)) ) {
return;
}
bool ok = false;
QInfinity::BrowserIter iter = iterForUrl(url, &ok);
if ( ! ok ) {
error(KIO::ERR_COULD_NOT_STAT, i18n("Could not stat %1: No such file or directory.", url.url()));
return;
}
UDSEntry entry;
if ( ! iter.isDirectory() ) {
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QString::fromLatin1("text/plain"));
}
entry.insert(KIO::UDSEntry::UDS_NAME, iter.name());
entry.insert(KIO::UDSEntry::UDS_SIZE, 0);
entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, iter.name());
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, iter.isDirectory() ? S_IFDIR : S_IFREG);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 07777);
statEntry(entry);
finished();
}
示例14: if
void Nepomuk2::TvshowProtocol::listDir( const KUrl& url )
{
// root folder
if(url.path().length() <= 1) {
// list all tv shows including title, description, and an optional depiction (for now we simply take one of them)
Soprano::QueryResultIterator it
= Nepomuk2::ResourceManager::instance()->mainModel()->executeQuery(QString::fromLatin1("select distinct ?r ?t ?d where { "
"?r a %1 . "
"?r %2 ?t . "
"?r %3 ?d . "
"?r %4 ?cd . "
"?r %5 ?md . }")
.arg(Soprano::Node::resourceToN3(NMM::TVSeries()),
Soprano::Node::resourceToN3(NIE::title()),
Soprano::Node::resourceToN3(NIE::description()),
Soprano::Node::resourceToN3(NAO::created()),
Soprano::Node::resourceToN3(NAO::lastModified())),
Soprano::Query::QueryLanguageSparql);
while(it.next()) {
UDSEntry uds = createSeriesUDSEntry(it["r"].uri(),
it["t"].toString(),
it["t"].toString(),
it["d"].toString(),
it["cd"].literal().toDateTime(),
it["md"].literal().toDateTime());
listEntry(uds, false);
}
KIO::UDSEntry uds = createFolderUDSEntry(QLatin1String("latest"), i18n("Next Episodes To Watch"));
uds.insert(KIO::UDSEntry::UDS_ICON_NAME, QLatin1String("favorites"));
listEntry(uds, false);
listEntry(UDSEntry(), true);
finished();
}
// all other URLS
else {
const QStringList pathTokens = url.path().split('/', QString::SkipEmptyParts);
if(pathTokens.count() == 1 && pathTokens.first() == QLatin1String("latest")) {
// list the next unwatched episodes of all series
// query the min episode which does not have any watched episode after it
// TODO: find a way to also query the episode at the same time
Soprano::QueryResultIterator it
= Nepomuk2::ResourceManager::instance()->mainModel()->executeQuery(QLatin1String("select ?st ?series min(1000*?s+?e) as ?x where { "
"?r a nmm:TVShow ; "
"nmm:episodeNumber ?e ; "
"nmm:season ?s ; "
"nmm:series ?series . "
"?series nie:title ?st "
"FILTER NOT EXISTS { ?r nuao:usageCount ?u . filter(?u>0) . } "
"FILTER NOT EXISTS { "
"?r2 a nmm:TVShow ; "
"nmm:series ?series ; "
"nmm:episodeNumber ?e2 ; "
"nmm:season ?s2 ; "
"nuao:usageCount ?uc . "
"filter(?uc>0) . "
"filter((1000*?s2+?e2) > (1000*?s+?e)) . } "
"}"),
Soprano::Query::QueryLanguageSparql);
while(it.next()) {
const QString seriesTitle = it["st"].toString();
const int seasonNum = it["x"].literal().toInt() / 1000;
const int episodeNum = it["x"].literal().toInt() % 1000;
Soprano::QueryResultIterator it2
= Nepomuk2::ResourceManager::instance()->mainModel()->executeQuery(QString::fromLatin1("select ?r ?url ?t where { "
"?r a nmm:TVShow ; "
"nie:url ?url ; "
"nie:title ?t ; "
"nmm:series %1 ; "
"nmm:episodeNumber %2 ; "
"nmm:season %3 . "
"OPTIONAL { ?r nmm:releaseDate ?rd ; "
"nmm:synopsis ?d . } . }")
.arg(it["series"].toN3())
.arg(episodeNum)
.arg(seasonNum),
Soprano::Query::QueryLanguageSparql);
if(it2.next()) {
const QString episodeTitle = it2["t"].toString();
const QString title = i18n("Next episode of %1: %2x%3 - %4",
seriesTitle,
QString::number(seasonNum).rightJustified(2, QLatin1Char('0')),
QString::number(episodeNum).rightJustified(2, QLatin1Char('0')),
episodeTitle);
UDSEntry uds;
uds.insert( KIO::UDSEntry::UDS_NAME, title );
uds.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG );
uds.insert( KIO::UDSEntry::UDS_DISPLAY_TYPE, i18n("TV Show") );
uds.insert( KIO::UDSEntry::UDS_ACCESS, 0700 );
uds.insert( KIO::UDSEntry::UDS_USER, KUser().loginName() );
uds.insert( KIO::UDSEntry::UDS_CREATION_TIME, it2["rd"].literal().toDateTime().toTime_t() );
uds.insert( KIO::UDSEntry::UDS_COMMENT, it2["d"].toString() );
uds.insert( KIO::UDSEntry::UDS_URL, KUrl(it2["url"].uri()).url() );
uds.insert( KIO::UDSEntry::UDS_NEPOMUK_URI, KUrl(it2["r"].uri()).url() );
listEntry(uds, false);
}
}
listEntry(UDSEntry(), true);
//.........这里部分代码省略.........
示例15: pathToUDSEntry
static const UDSEntry pathToUDSEntry(const QString& path, const QString& display,
const QString& url = QString(), const QString& icon = QString())
{
UDSEntry entry;
entry.insert(KIO::UDSEntry::UDS_NAME, display);
if (!path.isEmpty()) {
KDE_struct_stat info;
KDE_lstat(path.toLocal8Bit(), &info);
entry.insert(KIO::UDSEntry::UDS_SIZE, info.st_size);
entry.insert(KIO::UDSEntry::UDS_ACCESS, info.st_mode);
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, info.st_mtime);
entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, info.st_atime);
entry.insert(KIO::UDSEntry::UDS_CREATION_TIME, info.st_ctime);
struct passwd * user = getpwuid(info.st_uid);
struct group * group = getgrgid(info.st_gid);
entry.insert(KIO::UDSEntry::UDS_USER, ((user != NULL) ? user->pw_name : "???" ));
entry.insert(KIO::UDSEntry::UDS_GROUP, ((group != NULL) ? group->gr_name : "???" ));
if (url.isEmpty()) {
// List an existing file.
entry.insert(KIO::UDSEntry::UDS_URL, "file:" + path);
mode_t type = info.st_mode;
if (S_ISLNK(type)) {
QString slink;
char buff[1000];
int n = readlink(path.toLocal8Bit(), buff, 1000);
if (n != -1) {
buff[n] = 0;
slink = buff;
}
entry.insert(KIO::UDSEntry::UDS_LINK_DEST, slink);
} else {
type &= S_IFMT;
}
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, type);
if (path.contains("/.")) {
entry.insert(KIO::UDSEntry::UDS_HIDDEN, 1);
}
} else {
// List a locate link.
entry.insert(KIO::UDSEntry::UDS_URL, url);
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
}
} else {
entry.insert(KIO::UDSEntry::UDS_URL, url);
}
if (!icon.isEmpty()) {
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, icon);
}
return entry;
}