void
JXComposeRuleList::AddRule
	(
	const JArray<KeySym>&	inputSeq,
	const KeySym			outputKeySym
	)
{
	assert( !inputSeq.IsEmpty() );

	if (!IsInitialKeySym(inputSeq.GetFirstElement()))
		{
		itsInitialKeySymList->AppendElement(inputSeq.GetFirstElement());
		}

	Rule r(jnew JArray<KeySym>(inputSeq), outputKeySym);
	assert( r.inputSeq != NULL );
	itsRuleList->InsertSorted(r);
}
Beispiel #2
0
JBoolean
TestWidget::WillAcceptDrop
(
    const JArray<Atom>&	typeList,
    Atom*				action,
    const Time			time,
    const JXWidget*		source
)
{
    JXDNDManager* dndMgr = GetDNDManager();

    if (typeList.GetFirstElement() == (GetSelectionManager())->GetURLXAtom())
    {
        cout << endl;
        cout << "Accepting the drop of type text/uri-list" << endl;
        cout << endl;

        *action = dndMgr->GetDNDActionPrivateXAtom();
        return kJTrue;
    }
    else if (*action == dndMgr->GetDNDActionCopyXAtom())
    {
        cout << endl;
        cout << "Accepting the drop" << endl;
        cout << endl;

        PrintSelectionText(dndMgr->GetDNDSelectionName(), time,
                           (GetSelectionManager())->GetMimePlainTextXAtom());
        return kJTrue;
    }
    else
    {
        JXDisplay* display = GetDisplay();

        cout << endl;
        cout << "Not accepting the drop because the action isn't copy" << endl;
        cout << "Action: " << XGetAtomName(*display, *action) << endl;
        cout << endl;
        cout << "Data types available from DND source:" << endl;
        cout << endl;

        const JSize typeCount = typeList.GetElementCount();
        for (JIndex i=1; i<=typeCount; i++)
        {
            const Atom type = typeList.GetElement(i);
            cout << XGetAtomName(*display, type) << endl;
        }
        cout << endl;

        PrintSelectionText(dndMgr->GetDNDSelectionName(), time,
                           (GetSelectionManager())->GetMimePlainTextXAtom());

        return kJFalse;
    }
}
JBoolean
JGetUserMountPointList
	(
	JMountPointList*	list,
	JMountState*		state
	)
{
	JProcess* p;
	int outFD;
	const JError err = JProcess::Create(&p, kMountCmd,
										kJIgnoreConnection, NULL,
										kJCreatePipe, &outFD,
										kJIgnoreConnection, NULL);
	if (!err.OK())
		{
		if (state != NULL)
			{
			jdelete state->mountCmdOutput;
			state->mountCmdOutput = NULL;
			}
		return kJFalse;
		}

	JString mountData;
	JReadAll(outFD, &mountData);

	p->WaitUntilFinished();
	const JBoolean success = p->SuccessfulFinish();
	jdelete p;
	p = NULL;

	if (!success)
		{
		if (state != NULL)
			{
			jdelete state->mountCmdOutput;
			state->mountCmdOutput = NULL;
			}
		return kJFalse;
		}

	if (state != NULL && state->mountCmdOutput != NULL &&
		mountData == *(state->mountCmdOutput))
		{
		return kJFalse;
		}

	list->CleanOut();
	if (state != NULL && state->mountCmdOutput == NULL)
		{
		state->mountCmdOutput = jnew JString(mountData);
		assert( state->mountCmdOutput != NULL );
		}
	else if (state != NULL)
		{
		*(state->mountCmdOutput) = mountData;
		}

	JIndexRange r;
	JArray<JIndexRange> matchList;
	JString options;
	ACE_stat stbuf;
	while (theLinePattern.MatchAfter(mountData, r, &matchList))
		{
		r = matchList.GetFirstElement();

		options = mountData.GetSubstring(matchList.GetElement(4));
		if (options.Contains("nobrowse"))
			{
			continue;
			}

		JString* path = jnew JString(mountData.GetSubstring(matchList.GetElement(3)));
		assert( path != NULL );
		JString* devicePath = jnew JString(mountData.GetSubstring(matchList.GetElement(2)));
		assert( devicePath != NULL );

		const JMountType type =
			JGetUserMountPointType(*path, *devicePath, "");
		if (type == kJUnknownMountType ||
			ACE_OS::stat(*path, &stbuf) != 0)
			{
			jdelete path;
			jdelete devicePath;
			continue;
			}

		JFileSystemType fsType = kOtherFSType;
		if (options.Contains("msdos"))
			{
			fsType = kVFATType;
			}

		list->AppendElement(JMountPoint(path, type, stbuf.st_dev, devicePath, fsType));
		}

	return kJTrue;
}