static GroupId calculateGroupId(StyleBase* styleBase)
{
    ASSERT(styleBase);
    StyleBase* current = styleBase;
    StyleSheet* styleSheet = 0;
    while (true) {
        // Special case: CSSStyleDeclarations might be either inline and in this case
        // we need to group them with their node or regular ones.
        if (current->isMutableStyleDeclaration()) {
            CSSMutableStyleDeclaration* cssMutableStyleDeclaration = static_cast<CSSMutableStyleDeclaration*>(current);
            if (cssMutableStyleDeclaration->isInlineStyleDeclaration()) {
                ASSERT(cssMutableStyleDeclaration->parent()->isStyleSheet());
                return calculateGroupId(cssMutableStyleDeclaration->node());
            }
            // Either we have no parent, or this parent is a CSSRule.
            ASSERT(cssMutableStyleDeclaration->parent() == cssMutableStyleDeclaration->parentRule());
        }

        if (current->isStyleSheet())
            styleSheet = static_cast<StyleSheet*>(current);

        StyleBase* parent = current->parent();
        if (!parent)
            break;
        current = parent;
    }

    if (styleSheet) {
        if (Node* ownerNode = styleSheet->ownerNode())
            return calculateGroupId(ownerNode);
        return GroupId(styleSheet);
    }

    return GroupId(current);
}
示例#2
0
    void visitDOMWrapper(DOMDataStore* store, void* object, v8::Persistent<v8::Object> wrapper)
    {
        WrapperTypeInfo* typeInfo = V8DOMWrapper::domWrapperType(wrapper);

        if (typeInfo->isSubclass(&V8StyleSheetList::info)) {
            StyleSheetList* styleSheetList = static_cast<StyleSheetList*>(object);
            GroupId groupId(styleSheetList);
            if (Document* document = styleSheetList->document())
                groupId = GroupId(document);
            m_grouper.append(GrouperItem(groupId, wrapper));

        } else if (typeInfo->isSubclass(&V8DOMImplementation::info)) {
            DOMImplementation* domImplementation = static_cast<DOMImplementation*>(object);
            GroupId groupId(domImplementation);
            if (Document* document = domImplementation->document())
                groupId = GroupId(document);
            m_grouper.append(GrouperItem(groupId, wrapper));

        } else if (typeInfo->isSubclass(&V8StyleSheet::info) || typeInfo->isSubclass(&V8CSSRule::info)) {
            m_grouper.append(GrouperItem(calculateGroupId(static_cast<StyleBase*>(object)), wrapper));

#if 0 //CMP_ERROR_UNCLEAR CSSMutableStyleDeclaration
        } else if (typeInfo->isSubclass(&V8CSSStyleDeclaration::info)) {
            CSSStyleDeclaration* cssStyleDeclaration = static_cast<CSSStyleDeclaration*>(object);

            GroupId groupId = calculateGroupId(cssStyleDeclaration);
            m_grouper.append(GrouperItem(groupId, wrapper));

            // Keep alive "dirty" primitive values (i.e. the ones that
            // have user-added properties) by creating implicit
            // references between the style declaration and the values
            // in it.
            if (cssStyleDeclaration->isMutableStyleDeclaration()) {
                CSSMutableStyleDeclaration* cssMutableStyleDeclaration = static_cast<CSSMutableStyleDeclaration*>(cssStyleDeclaration);
                Vector<v8::Persistent<v8::Value> > values;
                values.reserveCapacity(cssMutableStyleDeclaration->length());
                CSSMutableStyleDeclaration::const_iterator end = cssMutableStyleDeclaration->end();
                for (CSSMutableStyleDeclaration::const_iterator it = cssMutableStyleDeclaration->begin(); it != end; ++it) {
                    v8::Persistent<v8::Object> value = store->domObjectMap().get(it->value());
                    if (!value.IsEmpty() && value->IsDirty())
                        values.append(value);
                }
                if (!values.isEmpty())
                    v8::V8::AddImplicitReferences(wrapper, values.data(), values.size());
            }
        } else if (typeInfo->isSubclass(&V8CSSRuleList::info)) {
            CSSRuleList* cssRuleList = static_cast<CSSRuleList*>(object);
            GroupId groupId(cssRuleList);
            StyleList* styleList = cssRuleList->styleList();
            if (styleList)
                groupId = calculateGroupId(styleList);
            m_grouper.append(GrouperItem(groupId, wrapper));
#endif
        }
    }
void
MetaDataStore::maybe_initialise_()
{
    if (not harakoon_.initialized())
    {
        LOG_INFO("Trying to initialize filesystem metadata store");
        try
        {
            harakoon_.initialize(DirectoryEntry(DirectoryEntry::Type::Directory,
                                                alloc_inode(),
                                                default_directory_permissions,
                                                UserId(::getuid()),
                                                GroupId(::getgid())));
            LOG_INFO("Initialized filesystem metadata store");
        }
        catch (ara::error_assertion_failed&)
        {
            // Another cluster node could've beaten us to it:
            if (not harakoon_.initialized())
            {
                throw;
            }
            else
            {
                LOG_INFO("Filesystem metadata store already initialized by another node");
            }
        }
    }
    else
    {
        LOG_INFO("Filesystem metadata store already initialized");
    }
}
示例#4
0
文件: cred.cpp 项目: monsterzz/porto
bool TCred::IsMemberOf(std::string groupname) const {
    gid_t gid;

    if (GroupId(groupname, gid))
        return false;

    return IsMemberOf(gid);
}
示例#5
0
// If the node is in document, put it in the ownerDocument's object group.
//
// If an image element was created by JavaScript "new Image",
// it is not in a document. However, if the load event has not
// been fired (still onloading), it is treated as in the document.
//
// Otherwise, the node is put in an object group identified by the root
// element of the tree to which it belongs.
static GroupId calculateGroupId(Node* node)
{
    if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && static_cast<HTMLImageElement*>(node)->hasPendingLoadEvent()))
        return GroupId(node->document());

    Node* root = node;
    if (node->isAttributeNode()) {
        root = static_cast<Attr*>(node)->ownerElement();
        // If the attribute has no element, no need to put it in the group,
        // because it'll always be a group of 1.
        if (!root)
            return GroupId();
    } else {
        while (Node* parent = root->parentOrHostNode())
            root = parent;
    }

    return GroupId(root);
}
示例#6
0
GroupId GroupId::fromData(QByteArray const& data) {
	if (data.size() < ((PROTO_GROUP_GROUPID_LENGTH_BYTES) + (PROTO_IDENTITY_LENGTH_BYTES))) {
		throw IllegalArgumentException() << "Need at least " << ((PROTO_GROUP_GROUPID_LENGTH_BYTES)+(PROTO_IDENTITY_LENGTH_BYTES)) << " Bytes for creating a Group Id from Data.";
	}

	ContactId const owner(data.mid(0, ContactId::getSizeOfContactIdInBytes()));
	quint64 groupId = ByteArrayConversions::convert8ByteQByteArrayToQuint64(data.mid(ContactId::getSizeOfContactIdInBytes(), PROTO_GROUP_GROUPID_LENGTH_BYTES));

	return GroupId(owner, groupId);
}
示例#7
0
文件: cred.cpp 项目: monsterzz/porto
void InitCred() {
    TError error;

    error = GroupId(PORTO_GROUP_NAME, PortoGroup);
    if (error)
        L_WRN() << "Cannot find group porto: " << error << std::endl;

    if (TPath("/proc/sys/kernel/cap_last_cap").ReadInt(LastCapability)) {
        L_WRN() << "Can't read /proc/sys/kernel/cap_last_cap, assuming 36" << std::endl;
        LastCapability = 36; //FIXME
    }
}
void ContactEditWizardPageDone::initializePage() {
	// all data in the Info section was given, now create the group
	// Generate new random ID as group identifier
	quint64 newGroupId = GroupContact::generateRandomGroupId();
	GroupContact* gc = new GroupContact(GroupId(clientConfiguration->getClientIdentity(), newGroupId));
	gc->setGroupName(field("edtName").toString());
	gc->addMember(clientConfiguration->getClientIdentity());

	// Send messages to members
	QMetaObject::invokeMethod(protocolClient, "sendGroupCreation", Q_ARG(quint64, newGroupId), Q_ARG(bool, true));
	QThread::msleep(100);
	QMetaObject::invokeMethod(protocolClient, "sendGroupTitle", Q_ARG(quint64, newGroupId), Q_ARG(QString const&, field("edtName").toString()));
}
示例#9
0
        GroupId group(GroupId parent)
        {
            beginMessage();

            const int32_t nodeId = m_engine->nodeIdAllocator().alloc();

            oscPacket()
                .openMessage("/group/new", 3)
                    .int32(nodeId)
                    .int32(parent.id())
                    .int32(0) // add action
                .closeMessage();

            return GroupId(nodeId);
        }
GroupLocationMessageContent::GroupLocationMessageContent() : GroupMessageContent(GroupId(0, 0)), latitude(0.0), longitude(0.0), height(0.0), description() {
	// Only accessible and used by the MessageContentFactory.
}
示例#11
0
	namespace UserUtils
	{
#if !defined( BLOCXX_WIN32 )
		const UserId INVALID_USERID = UserId(~0);
		const GroupId INVALID_GROUPID = GroupId(~0);
#endif


		/**
		 * Get the effective user id.  On POSIX platforms this calls geteuid().
		 *
		 * @return A string representation of the user id.  On POSIX
		 *   platforms, this can be converted to a UInt64.
		 */
		BLOCXX_COMMON_API String getEffectiveUserId();
		/**
		 * Get the effective group id.  On POSIX platforms this calls getegid().
		 *
		 * @return A string representation of the group id.  On POSIX
		 *   platforms, this can be converted to a UInt64.
		 */
		BLOCXX_COMMON_API String getEffectiveGroupId();
		/**
		 * Return the user name for the current user.
		 */
		BLOCXX_COMMON_API String getCurrentUserName();
		/**
		 * Return the group name for the current user.
		 */
		BLOCXX_COMMON_API String getCurrentGroupName();
		/**
		 * If the username is invalid, or if getUserName() fails for any other
		 * reason, 'success' will be set to false. On success, 'success' is
		 * set to true.
		 * @param uid The id to query for user name
		 * @return The user name corresponding to the requested uid, or
		 *   an empty string on failure.  Check success before relying
		 *   on the return result.
		 *
		 * \example utils.cpp
		 */
		BLOCXX_COMMON_API String getUserName(UserId uid, bool& success);
		/**
		 * If the group is invalid, or if getGropuName() fails for any other
		 * reason, 'success' will be set to false. On success, 'success' is
		 * set to true.
		 * @param gid The id to query for group name
		 * @return The group name corresponding to the requested gid, or
		 *   an empty string on failure.  Check success before relying
		 *   on the return result.
		 *
		 * \example utils.cpp
		 */
		BLOCXX_COMMON_API String getGroupName(GroupId gid, bool& success);

		/**
		 * Convert a textual username into a platform native user type.
		 * @param userName The user name to convert.
		 * @param validUserName Out param set to true if the conversion was successful, false otherwise.
		 * @return The user id corresponding to userName.
		 *
		 * \example utils.cpp
		 */
		BLOCXX_COMMON_API UserId getUserId(const String& userName, bool& validUserName);
		/**
		 * Convert a textual group name into a platform native group type.
		 * @param groupName The group name to convert.
		 * @param validGroupName Out param set to true if the conversion was successful, false otherwise.
		 * @return The group id corresponding to groupName.
		 *
		 * \example utils.cpp
		 */
		BLOCXX_COMMON_API UserId getGroupId(const String& groupName, bool& validGroupName);

	} // end namespace UserUtils
示例#12
0
void
MetaDataStore::add_directories(const FrontendPath& path)
{
    LOG_TRACE(path);

    FrontendPath p;

    for (const auto& s : path)
    {
        p = FrontendPath(p / s);
        DirectoryEntryPtr dentry(find(p));

        while (true)
        {
            if (dentry == nullptr)
            {
                DirectoryEntryPtr
                    dentry(boost::make_shared<DirectoryEntry>(DirectoryEntry::Type::Directory,
                                                              alloc_inode(),
                                                              default_directory_permissions,
                                                              UserId(::getuid()),
                                                              GroupId(::getgid())));
                try
                {
                    struct timespec timebuf;
                    struct timeval tv;

                    TODO("X42: Better use fungi::IOException here? WIP");
                    int rc = clock_gettime(CLOCK_REALTIME, &timebuf);
                    if (rc != 0)
                    {
                        throw std::system_error(errno, std::system_category());
                    }

                    add(p, dentry);

                    tv.tv_sec = timebuf.tv_sec;
                    tv.tv_usec = timebuf.tv_nsec / 1000;
                    utimes(FrontendPath(p.parent_path()),
                           tv,
                           tv);
                    break;
                }
                catch (FileExistsException&)
                {
                    LOG_WARN(p << ": someone else created an eponymous entry at the same time");
                }
            }
            else
            {
                if (dentry->type() != DirectoryEntry::Type::Directory)
                {
                    LOG_ERROR(p << " already exists but is not a directory");
                    throw fungi::IOException("Entry is not a directory",
                                             p.string().c_str(),
                                             ENOTDIR);
                }

                break;
            }
        }
    }
}
GroupLeaveMessageContent::GroupLeaveMessageContent() : GroupMessageContent(GroupId(0, 0)), leavingContactId(0) {
	// Only accessible and used by the MessageContentFactory.
}
示例#14
0
GroupId GroupId::createRandomGroupId(ContactId const& owner) {
	quint64 result = 0;
	randombytes_buf(&result, sizeof(quint64));

	return GroupId(owner, result);
}
GroupTextMessageContent::GroupTextMessageContent() : GroupMessageContent(GroupId(0, 0)), text() {
	// Only accessible and used by the MessageContentFactory.
}
/* readonly attribute AString groupId; */
NS_IMETHODIMP
nsPerformanceGroupDetails::GetGroupId(nsAString& aGroupId) {
  aGroupId.Assign(GroupId());
  return NS_OK;
};
示例#17
0
void ContactRegistry::fromFile(QString const& filename, bool dryRun) {
	if (!QFile::exists(filename)) {
		throw IllegalArgumentException() << QString("Could not open the specified contacts file as it does not exist: %1").arg(filename).toStdString();
	}
	QFile inputFile(filename);
	if (!inputFile.open(QFile::ReadOnly | QFile::Text)) {
		throw IllegalArgumentException() << QString("Could not open the specified contacts file for reading: %1").arg(filename).toStdString();
	}

	QRegExp commentRegExp("^\\s*#.*$", Qt::CaseInsensitive, QRegExp::RegExp2);
	QRegExp identityRegExp("^\\s*([A-Z0-9]{8})\\s*:\\s*([a-fA-F0-9]{64})\\s*(?::\\s*(.*)\\s*)?$", Qt::CaseInsensitive, QRegExp::RegExp2);
	QRegExp groupRegExp("^\\s*([a-fA-F0-9]{16})\\s*:\\s*([A-Z0-9]{8})\\s*:\\s*([A-Z0-9]{8}(?:\\s*,\\s*[A-Z0-9]{8})*)\\s*:\\s*(.*)\\s*$", Qt::CaseInsensitive, QRegExp::RegExp2);

	QTextStream in(&inputFile);
	in.setCodec("UTF-8"); // change the file codec to UTF-8.
	while (!in.atEnd()) {
		QString line = in.readLine().trimmed();
		if (line.isEmpty() || commentRegExp.exactMatch(line)) {
			continue;
		} else if (identityRegExp.exactMatch(line)) {
			if (!dryRun) {
				accessMutex.lock();

				ContactId const contactId(identityRegExp.cap(1));
				IdentityContact* iContact = new IdentityContact(contactId, PublicKey::fromHexString(identityRegExp.cap(2)));
				if (!identityRegExp.cap(3).trimmed().isEmpty()) {
					// Nickname given.
					iContact->setNickname(identityRegExp.cap(3).trimmed());
				}
				connectContact(iContact);
				identityToIdentityContactHashMap.insert(contactId, iContact);

				accessMutex.unlock();
			}
		} else if (groupRegExp.exactMatch(line)) {
			if (!dryRun) {
				accessMutex.lock();

				quint64 groupIdentity = IdentityHelper::groupIdByteArrayToUint64(QByteArray::fromHex(groupRegExp.cap(1).toLatin1()));
				quint64 groupOwner = IdentityHelper::identityStringToUint64(groupRegExp.cap(2));
				GroupContact* gContact = new GroupContact(GroupId(groupOwner, groupIdentity));
				if (!groupRegExp.cap(4).trimmed().isEmpty()) {
					gContact->setGroupName(groupRegExp.cap(4).trimmed());
				}

				QStringList ids = groupRegExp.cap(3).split(',', QString::SkipEmptyParts);
				if (ids.size() == 0) {
					throw IllegalArgumentException() << QString("Invalid or ill-formated line in contacts file \"%1\".\nProblematic line: %2").arg(filename).arg(line).toStdString();
				}

				QStringList::const_iterator it = ids.constBegin();
				QStringList::const_iterator end = ids.constEnd();
				for (; it != end; ++it) {
					QString trimmedId(it->trimmed());
					ContactId const memberId(trimmedId);
					gContact->addMember(memberId);
				}

				connectContact(gContact);
				identityToGroupContactHashMap.insert(GroupId(groupOwner, groupIdentity), gContact);

				accessMutex.unlock();
			}
		} else {
			throw IllegalArgumentException() << QString("Invalid or ill-formated line in contacts file \"%1\".\nProblematic line: %2").arg(filename).arg(line).toStdString();
		}
	}

	inputFile.close();
	if (!dryRun) {
		emit identitiesChanged();
	}
}
示例#18
0
 GroupId root() const
 {
     return GroupId(0);
 }