QString KFileItem::permissionsString() const { if (m_access.isNull()) m_access = parsePermissions( m_permissions ); return m_access; }
static aclList parsePolicyXml(xmlNode * a_node) { xmlNode *cur_node = a_node; aclList policyList = null; if (cur_node && cur_node->type == XML_ELEMENT_NODE && !strcmp(cur_node->name, policyTagName)) { policyList = getNewPolicyList(); for (cur_node = a_node->children; cur_node; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { if (!strcmp(cur_node->name, permissionsTagName)) { if (!parsePermissions(cur_node, policyList)) { freePolicyList(policyList); policyList = null; break; } } else { fprintf(stderr, "\nInvalid Element:%s\n", cur_node->name); freePolicyList(policyList); policyList = null; break; } } } } else { fprintf(stderr, "Expected element : %s, as root node but found:%s", policyTagName, cur_node->name); } return policyList; }
void initPermissions(void) { char *password; unsigned permission; const struct config_param *param; permission_passwords = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); permission_default = PERMISSION_READ | PERMISSION_ADD | PERMISSION_CONTROL | PERMISSION_ADMIN; param = config_get_next_param(CONF_PASSWORD, NULL); if (param) { permission_default = 0; do { const char *separator = strchr(param->value, PERMISSION_PASSWORD_CHAR); if (separator == NULL) MPD_ERROR("\"%c\" not found in password string " "\"%s\", line %i", PERMISSION_PASSWORD_CHAR, param->value, param->line); password = g_strndup(param->value, separator - param->value); permission = parsePermissions(separator + 1); g_hash_table_replace(permission_passwords, password, GINT_TO_POINTER(permission)); } while ((param = config_get_next_param(CONF_PASSWORD, param))); } param = config_get_param(CONF_DEFAULT_PERMS); if (param) permission_default = parsePermissions(param->value); }
QString KFileItem::getToolTipText(int maxcount) { // we can return QString::null if no tool tip should be shown QString tip; KFileMetaInfo info = metaInfo(); // the font tags are a workaround for the fact that the tool tip gets // screwed if the color scheme uses white as default text color const char* start = "<tr><td><nobr><font color=\"black\">"; const char* mid = "</font></nobr></td><td><nobr><font color=\"black\">"; const char* end = "</font></nobr></td></tr>"; tip = "<table cellspacing=0 cellpadding=0>"; tip += start + i18n("Name:") + mid + text() + end; tip += start + i18n("Type:") + mid; QString type = QStyleSheet::escape(mimeComment()); if ( m_bLink ) { tip += i18n("Link to %1 (%2)").arg(linkDest(), type) + end; } else tip += type + end; if ( !S_ISDIR ( m_fileMode ) ) { bool hasSize; KIO::filesize_t sizeValue = size(hasSize); if(hasSize) tip += start + i18n("Size:") + mid + KIO::convertSizeWithBytes(sizeValue) + end; } QString timeStr = timeString( KIO::UDS_MODIFICATION_TIME); if(!timeStr.isEmpty()) tip += start + i18n("Modified:") + mid + timeStr + end; #ifndef Q_WS_WIN //TODO: show win32-specific permissions QString userStr = user(); QString groupStr = group(); if(!userStr.isEmpty() || !groupStr.isEmpty()) tip += start + i18n("Owner:") + mid + userStr + " - " + groupStr + end + start + i18n("Permissions:") + mid + parsePermissions(m_permissions) + end; #endif if (info.isValid() && !info.isEmpty() ) { tip += "<tr><td colspan=2><center><s> </s></center></td></tr>"; QStringList keys = info.preferredKeys(); // now the rest QStringList::Iterator it = keys.begin(); for (int count = 0; count<maxcount && it!=keys.end() ; ++it) { KFileMetaInfoItem item = info.item( *it ); if ( item.isValid() ) { QString s = item.string(); if ( ( item.attributes() & KFileMimeTypeInfo::SqueezeText ) && s.length() > 50) { s.truncate(47); s.append("..."); } if ( !s.isEmpty() ) { count++; tip += start + QStyleSheet::escape( item.translatedKey() ) + ":" + mid + QStyleSheet::escape( s ) + end; } } } } tip += "</table>"; //kdDebug() << "making this the tool tip rich text:\n"; //kdDebug() << tip << endl; return tip; }