kerneltest/f32test/shostmassstorage/msman/client/rusbhostsession.cpp
changeset 300 1d28c8722707
parent 0 a41df078684a
equal deleted inserted replaced
293:0659d0e1a03c 300:1d28c8722707
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    24 #include <e32std.h>
    24 #include <e32std.h>
    25 #include <f32file.h>
    25 #include <f32file.h>
    26 
    26 
    27 #include "msmanclientserver.h"
    27 #include "msmanclientserver.h"
    28 #include "rusbhostsession.h"
    28 #include "rusbhostsession.h"
    29 #include "tmslog.h"
       
    30 #include "debug.h"
    29 #include "debug.h"
    31 
    30 
    32 
    31 
    33 TVersion RUsbHostSession::Version() const
    32 TVersion RUsbHostSession::Version() const
    34     {
    33     {
    35     __MSFNSLOG
       
    36     return(TVersion(KUsbHostSrvMajorVersionNumber,
    34     return(TVersion(KUsbHostSrvMajorVersionNumber,
    37                     KUsbHostSrvMinorVersionNumber,
    35                     KUsbHostSrvMinorVersionNumber,
    38                     KUsbHostSrvBuildVersionNumber));
    36                     KUsbHostSrvBuildVersionNumber));
    39     }
    37     }
    40 
    38 
    41 
    39 
    42 EXPORT_C RUsbHostSession::RUsbHostSession()
    40 EXPORT_C RUsbHostSession::RUsbHostSession()
    43     {
    41     {
    44     __MSFNSLOG
       
    45     }
    42     }
    46 
    43 
    47 
    44 
    48 EXPORT_C TInt RUsbHostSession::Connect()
    45 EXPORT_C TInt RUsbHostSession::Connect()
    49     {
    46     {
    50     __MSFNSLOG
       
    51 
       
    52     TInt retry = 2;
    47     TInt retry = 2;
    53     for (;;)
    48     for (;;)
    54         {
    49         {
    55         TInt r = CreateSession(KUsbHostServerName, Version());
    50         TInt r = CreateSession(KUsbHostServerName, Version());
    56         if ((r != KErrNotFound) && (r != KErrServerTerminated))
    51         if ((r != KErrNotFound) && (r != KErrServerTerminated))
    71     }
    66     }
    72 
    67 
    73 
    68 
    74 TInt RUsbHostSession::StartServer()
    69 TInt RUsbHostSession::StartServer()
    75     {
    70     {
    76     __MSFNSLOG
       
    77 
       
    78     const TUidType serverUid(KNullUid, KNullUid, KUsbHostServerUid3);
    71     const TUidType serverUid(KNullUid, KNullUid, KUsbHostServerUid3);
    79 
    72 
    80     // Create the server process
    73     // Create the server process
    81     RProcess server;
    74     RProcess server;
    82     TInt r = server.Create(KUsbHostServerName, KNullDesC, serverUid);
    75     TInt r = server.Create(KUsbHostServerName, KNullDesC, serverUid);
    94         server.Kill(0);    // If the outstanding request is not pending then kill the server
    87         server.Kill(0);    // If the outstanding request is not pending then kill the server
    95         server.Close();
    88         server.Close();
    96         return status.Int();
    89         return status.Int();
    97         }
    90         }
    98 
    91 
    99 	server.SetPriority(EPriorityHigh);
    92     server.SetPriority(EPriorityHigh);
   100     server.Resume(); // start the server
    93     server.Resume(); // start the server
   101 
    94 
   102     // Test whether the process has ended and if it has ended, return how it ended.
    95     // Test whether the process has ended and if it has ended, return how it ended.
   103     User::WaitForRequest(status);
    96     User::WaitForRequest(status);
   104 
    97 
   113     }
   106     }
   114 
   107 
   115 
   108 
   116 
   109 
   117 EXPORT_C TInt RUsbHostSession::Start()
   110 EXPORT_C TInt RUsbHostSession::Start()
   118 	{
   111     {
   119 	return SendReceive(EUsbHostStart);
   112     return SendReceive(EUsbHostStart);
   120 	}
   113     }