kerneltest/f32test/shostmassstorage/msman/client/rusbotgsession.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".
    26 #include <e32std.h>
    26 #include <e32std.h>
    27 #include <f32file.h>
    27 #include <f32file.h>
    28 
    28 
    29 #include "msmanclientserver.h"
    29 #include "msmanclientserver.h"
    30 #include "rusbotgsession.h"
    30 #include "rusbotgsession.h"
    31 #include "tmslog.h"
       
    32 #include "debug.h"
    31 #include "debug.h"
    33 
    32 
    34 
    33 
    35 TVersion RUsbOtgSession::Version() const
    34 TVersion RUsbOtgSession::Version() const
    36     {
    35     {
    37     __MSFNSLOG
       
    38     return(TVersion(KUsbOtgSrvMajorVersionNumber,
    36     return(TVersion(KUsbOtgSrvMajorVersionNumber,
    39                     KUsbOtgSrvMinorVersionNumber,
    37                     KUsbOtgSrvMinorVersionNumber,
    40                     KUsbOtgSrvBuildVersionNumber));
    38                     KUsbOtgSrvBuildVersionNumber));
    41     }
    39     }
    42 
    40 
    43 
    41 
    44 EXPORT_C RUsbOtgSession::RUsbOtgSession()
    42 EXPORT_C RUsbOtgSession::RUsbOtgSession()
    45     {
    43     {
    46     __MSFNSLOG
       
    47     }
    44     }
    48 
    45 
    49 
    46 
    50 EXPORT_C RUsbOtgSession::RUsbOtgSession(TInt /* aParam */)
    47 EXPORT_C RUsbOtgSession::RUsbOtgSession(TInt /* aParam */)
    51     {
    48     {
    52     __MSFNSLOG
       
    53     }
    49     }
    54 
    50 
    55 EXPORT_C TInt RUsbOtgSession::Connect()
    51 EXPORT_C TInt RUsbOtgSession::Connect()
    56     {
    52     {
    57     __MSFNSLOG
       
    58 
       
    59     TInt retry = 2;
    53     TInt retry = 2;
    60     for (;;)
    54     for (;;)
    61         {
    55         {
    62         TInt r = CreateSession(KUsbOtgServerName, Version());
    56         TInt r = CreateSession(KUsbOtgServerName, Version());
    63         if ((r != KErrNotFound) && (r != KErrServerTerminated))
    57         if ((r != KErrNotFound) && (r != KErrServerTerminated))
    78     }
    72     }
    79 
    73 
    80 
    74 
    81 TInt RUsbOtgSession::StartServer()
    75 TInt RUsbOtgSession::StartServer()
    82     {
    76     {
    83     __MSFNSLOG
       
    84 
       
    85     const TUidType serverUid(KNullUid, KNullUid, KUsbOtgServerUid3);
    77     const TUidType serverUid(KNullUid, KNullUid, KUsbOtgServerUid3);
    86 
    78 
    87     // Create the server process
    79     // Create the server process
    88     RProcess server;
    80     RProcess server;
    89     TInt r = server.Create(KUsbOtgServerName, KNullDesC, serverUid);
    81     TInt r = server.Create(KUsbOtgServerName, KNullDesC, serverUid);
   101         server.Kill(0);    // If the outstanding request is not pending then kill the server
    93         server.Kill(0);    // If the outstanding request is not pending then kill the server
   102         server.Close();
    94         server.Close();
   103         return status.Int();
    95         return status.Int();
   104         }
    96         }
   105 
    97 
   106 	server.SetPriority(EPriorityHigh);
    98     server.SetPriority(EPriorityHigh);
   107     server.Resume(); // start the server
    99     server.Resume(); // start the server
   108 
   100 
   109     // Test whether the process has ended and if it has ended, return how it ended.
   101     // Test whether the process has ended and if it has ended, return how it ended.
   110     User::WaitForRequest(status);
   102     User::WaitForRequest(status);
   111 
   103 
   120     }
   112     }
   121 
   113 
   122 
   114 
   123 EXPORT_C TBool RUsbOtgSession::DeviceInserted()
   115 EXPORT_C TBool RUsbOtgSession::DeviceInserted()
   124     {
   116     {
   125     __MSFNSLOG
       
   126     TPckgBuf<TBool> pckg;
   117     TPckgBuf<TBool> pckg;
   127     TIpcArgs args(&pckg);
   118     TIpcArgs args(&pckg);
   128 
   119 
   129     SendReceive(EUsbOtgDeviceInserted, args);
   120     SendReceive(EUsbOtgDeviceInserted, args);
   130     TBool res = pckg();
   121     TBool res = pckg();
   132     }
   123     }
   133 
   124 
   134 
   125 
   135 EXPORT_C void RUsbOtgSession::NotifyChange(TBool& /* aChanged */, TRequestStatus& aStatus)
   126 EXPORT_C void RUsbOtgSession::NotifyChange(TBool& /* aChanged */, TRequestStatus& aStatus)
   136     {
   127     {
   137     __MSFNSLOG
       
   138     TPckgBuf<TBool> pckg;
   128     TPckgBuf<TBool> pckg;
   139     TIpcArgs args(&pckg);
   129     TIpcArgs args(&pckg);
   140 
   130 
   141     SendReceive(EUsbOtgNotifyChange, args, aStatus);
   131     SendReceive(EUsbOtgNotifyChange, args, aStatus);
   142     }
   132     }
   143 
   133 
   144 
   134 
   145 EXPORT_C TInt RUsbOtgSession::NotifyChangeCancel()
   135 EXPORT_C TInt RUsbOtgSession::NotifyChangeCancel()
   146     {
   136     {
   147     __MSFNSLOG
       
   148     return SendReceive(EUsbOtgNotifyChangeCancel);
   137     return SendReceive(EUsbOtgNotifyChangeCancel);
   149     }
   138     }
   150 
   139 
   151 
   140 
   152 EXPORT_C TInt RUsbOtgSession::BusDrop()
   141 EXPORT_C TInt RUsbOtgSession::BusDrop()
   153 	{
   142     {
   154     __MSFNSLOG
   143     return SendReceive(EUsbOtgBusDrop);
   155 	return SendReceive(EUsbOtgBusDrop);
   144     }
   156 	}