usbengines/usbwatcher/src/rusbwatcher.cpp
changeset 0 1e05558e2206
equal deleted inserted replaced
-1:000000000000 0:1e05558e2206
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This class implements UsbWatcher Server API
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32uid.h>
       
    19 #include <e32base.h>
       
    20 #include <usb.h>
       
    21 #include <usbwatcher.h>
       
    22 #include "rusbwatcher.h"
       
    23 #include "usbwatchershared.h"
       
    24 #include "debug.h"
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // C++ default constructor can NOT contain any code, that might leave.
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 EXPORT_C RUsbWatcher::RUsbWatcher()
       
    31     {
       
    32     LOG_FUNC
       
    33     
       
    34     }
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // C++ default destructor can NOT contain any code, that might leave.
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C RUsbWatcher::~RUsbWatcher()
       
    41     {
       
    42     LOG_FUNC
       
    43 
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // Server version.
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C TVersion RUsbWatcher::Version() const
       
    51     {
       
    52     LOG_FUNC
       
    53 
       
    54     return( TVersion( KUsbWatcherSrvMajorVersionNumber,
       
    55             KUsbWatcherSrvMinorVersionNumber,
       
    56             KUsbWatcherSrvBuildVersionNumber ) );
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // Creates session to UsbWatcher server.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C TInt RUsbWatcher::Connect()
       
    64     {
       
    65     LOG_FUNC
       
    66     
       
    67     return CreateSession( KUsbWatcherServerName, Version(), 10 );
       
    68     }
       
    69     
       
    70 // ---------------------------------------------------------------------------
       
    71 // Set new personality. If USB cable is connected change will happen
       
    72 // immediately.
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C void RUsbWatcher::SetPersonality( TRequestStatus& aStatus, 
       
    76     TInt aPersonalityId, TBool aForce, TBool aNonBlocking )
       
    77     {   
       
    78     LOG_FUNC
       
    79 
       
    80     TIpcArgs ipcArgs( aPersonalityId, aForce, aNonBlocking );
       
    81     SendReceive( EUsbWatcherSetPersonality, ipcArgs, aStatus );
       
    82     }
       
    83     
       
    84 // ---------------------------------------------------------------------------
       
    85 // Cancel setting of new personality. 
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 EXPORT_C void RUsbWatcher::CancelSetPersonality()
       
    89     {
       
    90     LOG_FUNC
       
    91 
       
    92     SendReceive( EUsbWatcherCancelSetPersonality );
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // Set previous personality. 
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 EXPORT_C void RUsbWatcher::SetPreviousPersonality( TRequestStatus& aStatus )
       
   100     {
       
   101     LOG_FUNC
       
   102 
       
   103     SendReceive( EUsbWatcherSetPreviousPersonality, aStatus );
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // Set previous personality synchronously. Request is completed before
       
   108 // it has been finished.
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 EXPORT_C void RUsbWatcher::SetPreviousPersonality()
       
   112     {
       
   113     LOG_FUNC
       
   114 
       
   115     SendReceive( EUsbWatcherSetPreviousPersonalitySync );
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // Cancel setting of previous personality. 
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 EXPORT_C void RUsbWatcher::CancelSetPreviousPersonality()
       
   123     {
       
   124     LOG_FUNC
       
   125 
       
   126     SendReceive( EUsbWatcherCancelSetPreviousPersonality );
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // Set previous personality when cable is disconnected. This will do nothing
       
   131 // if cable isn't connected.
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C void RUsbWatcher::SetPreviousPersonalityOnDisconnect()
       
   135     {
       
   136     LOG_FUNC
       
   137 
       
   138     SendReceive( EUsbWatcherSetPreviousPersonalityOnDisconnect );
       
   139     }
       
   140 
       
   141 // End of file