Esempio n. 1
0
static TInt MainL()
{
    RDebug::Print(_L("Main() - Starting!"));

    RFs theFs;

    TInt r = theFs.Connect();
    if (r != KErrNone)
    {
        RDebug::Print(_L("Main() - Failed to connect to the fs. Error = %d"), r);
        return r;
    }

    RDebug::Print(_L("Main() - Connected to file server"));

    r = StartC32();
    if (r!=KErrNone && r !=KErrAlreadyExists)
    {
        RDebug::Print(_L("Main() - Failed to start C32. Error = %d"), r);
        return r;
    }

    RDebug::Print(_L("E32Main: Started c32"));

    RUsb usb;
    TInt err = usb.Connect();
    if (err != KErrNone)
    {
        RDebug::Print(_L("MainL() - Unable to Connect to USB server"));
        theFs.Close();
        return err;
    }
    RDebug::Print(_L("MainL() - Connected to USB server"));

    TUsbServiceState state;

    err = usb.GetCurrentState(state);
    if (err != KErrNone)
    {
        RDebug::Print(_L("MainL() - Failed to fetch service state from usbman, error %d"), err);
    }
    else
    {
        RDebug::Print(_L("MainL() - Usb service state = 0x%x"), state);
    }

    TRequestStatus status;
    usb.Start(status);
    User::WaitForRequest(status);

    RDebug::Print(_L("Start completed with status %d"), status.Int());

    theFs.Close();
    RDebug::Print(_L("MainL() - Exiting normally"));
    return KErrNone;
}