Ejemplo n.º 1
0
void EditorGetCurrentLine(const FunctionCallbackInfo<Value>& args)
{
	CComPtr<VirtualPoint> virtualPoint;
	CComPtr<EditPoint> editPoint;

	long lineLen;
	BSTR currentLine;
    BSTR retVal;

	g_Options.m_selection->get_ActivePoint(&virtualPoint);
	virtualPoint->CreateEditPoint(&editPoint);
	editPoint->StartOfLine();
	editPoint->get_LineLength(&lineLen);
	editPoint->GetText(CComVariant(lineLen), &currentLine);

    StripCarriageReturns(currentLine, &retVal);

    args.GetReturnValue().Set(String::New(retVal, SysStringLen(retVal)));

    SysFreeString(retVal);
}
Ejemplo n.º 2
0
void EditorGetSelection(const FunctionCallbackInfo<Value>& args)
{
	CComPtr<VirtualPoint> virtualPoint;
    BSTR buf;
    BSTR retVal;

	g_Options.m_selection->get_Text(&buf);

	int retValLen = SysStringLen(buf);
    if (0 == retValLen)
    {
        args.GetReturnValue().Set(String::New(L""));
        SysFreeString(buf);
        return;
    }

    StripCarriageReturns(buf, &retVal);

    args.GetReturnValue().Set(String::New(retVal, SysStringLen(retVal)));

    SysFreeString(retVal);
}
Ejemplo n.º 3
0
void EditorGetContent(const FunctionCallbackInfo<Value>& args)
{
	CComPtr<TextPoint> startPoint;
	CComPtr<TextPoint> endPoint;
	CComPtr<EditPoint> startEditPoint;
	CComPtr<EditPoint> endEditPoint;
	BSTR buf;
    BSTR retVal;

	g_Options.m_textDoc->get_StartPoint(&startPoint);
	g_Options.m_textDoc->get_EndPoint(&endPoint);
	startPoint->CreateEditPoint(&startEditPoint);
	endPoint->CreateEditPoint(&endEditPoint);

	startEditPoint->GetText(CComVariant(endEditPoint), &buf);

    StripCarriageReturns(buf, &retVal);

	args.GetReturnValue().Set(String::New(retVal, SysStringLen(retVal)));

    SysFreeString(retVal);
}
Ejemplo n.º 4
0
void IPProbe::Tick ( int n )
{

	if ( IsInterfaceVisible () ) {

		if ( status == PROBE_IDLE ) {

			// Do nothing

		}
		else if ( status == PROBE_INPROGRESS ) {

			if ( time(NULL) >= timeout ) {

				// Try to lookup the IP in the box

				int pid = SvbLookupPID ( this );
				char name_display [64];
				UplinkSnprintf ( name_display, sizeof ( name_display ), "probe_display %d", pid );

				Button *button = EclGetButton ( name_display );
				UplinkAssert ( button );
				char *ip = StripCarriageReturns ( button->caption );

				VLocation *vl = game->GetWorld ()->GetVLocation ( ip );

				if ( vl ) {

					Computer *comp = vl->GetComputer ();
					UplinkAssert (comp);

					std::ostrstream body;
					body << "Results of IP Probe\n\n"
						 << "IP: " << comp->ip << "\n"
						 << "(" << comp->name << ")\n"
						 << "\n";

					for ( int i = 0; i < comp->security.NumSystems (); ++i ) {

						SecuritySystem *ss = comp->security.GetSystem (i);
						if ( ss ) {

							if		( version == 1.0 ) body << ss->GetName () << "\n";
							else if ( version == 2.0 ) body << ss->GetName () << " level " << ss->level << "\n";
							else if ( version == 3.0 ) {
								body << ss->GetName () << " level " << ss->level << "\n";
								if ( ss->bypassed ) body << "bypassed\n";
								if ( ss->enabled  ) body << "enabled\n";
								if ( !ss->enabled ) body << "disabled\n";
							}

						}

					}

					body << '\x0';

					// Found - send a message to the player with the details
					Message *msg = new Message ();
					msg->SetTo ( "PLAYER" );
					msg->SetFrom ( "IP Probe" );
					msg->SetSubject ( "Results of probe" );
					msg->SetBody ( body.str () );
					msg->Send ();

					body.rdbuf()->freeze( 0 );
					//delete [] body.str ();

				}
				else {

					// Not found
					EclRegisterCaptionChange ( name_display, "IP Not found" );

				}

                delete [] ip;
				timeout = (int) ( time(NULL) + 5 );
				status = PROBE_FINISHED;

			}

		}
		else if ( status == PROBE_FINISHED ) {

			// Revert to idle after 5 secs

			if ( time (NULL) > timeout ) {

				int pid = SvbLookupPID ( this );
				char name_display [64];
				UplinkSnprintf ( name_display, sizeof ( name_display ), "probe_display %d", pid );

				EclRegisterCaptionChange ( name_display, "Enter IP" );
				status = PROBE_IDLE;

			}

		}
		else {

			UplinkAbort ( "Unkown Status" );

		}

	}

}