Qt 4.8
Public Functions | Private Types | List of all members
RUsbOstComm Class Reference

#include <usbostcomm.h>

Inheritance diagram for RUsbOstComm:

Public Functions

TInt Close ()
 
TInt Connect ()
 
TInt Disconnect ()
 
TInt Open ()
 
TInt ReadCancel ()
 
void ReadMessage (TRequestStatus &aStatus, TDes8 &aDes)
 
TInt RegisterProtocolID (TOstProtIds aId, TBool aNeedHeader)
 
 RUsbOstComm ()
 
TVersion Version () const
 
void WriteMessage (TRequestStatus &aStatus, const TDesC8 &aDes, TBool aHasHeader=EFalse)
 

Private Types

enum  TUsbOstCmdCode {
  EUsbOstCmdCodeFirst, EUsbOstCmdConnect, EUsbOstCmdDisconnect, EUsbOstCmdCodeGetAcmConfig,
  EUsbOstCmdCodeSetAcmConfig, EUsbOstCmdCodeOpen, EUsbOstCmdCodeClose, EUsbOstCmdCodeRegisterId,
  EUsbOstCmdCodeRegisterIds, EUsbOstCmdCodeUnRegisterId, EUsbOstCmdCodeUnRegisterIds, EUsbOstCmdCodeReadMsg,
  EUsbOstCmdCodeReadCancel, EUsbOstCmdCodeWriteMsg, EUsbOstCmdCodeWriteCancel, EUsbOstCmdCodeLast
}
 

Detailed Description

Definition at line 52 of file usbostcomm.h.

Enumerations

◆ TUsbOstCmdCode

Enumerator
EUsbOstCmdCodeFirst 
EUsbOstCmdConnect 
EUsbOstCmdDisconnect 
EUsbOstCmdCodeGetAcmConfig 
EUsbOstCmdCodeSetAcmConfig 
EUsbOstCmdCodeOpen 
EUsbOstCmdCodeClose 
EUsbOstCmdCodeRegisterId 
EUsbOstCmdCodeRegisterIds 
EUsbOstCmdCodeUnRegisterId 
EUsbOstCmdCodeUnRegisterIds 
EUsbOstCmdCodeReadMsg 
EUsbOstCmdCodeReadCancel 
EUsbOstCmdCodeWriteMsg 
EUsbOstCmdCodeWriteCancel 
EUsbOstCmdCodeLast 

Definition at line 67 of file usbostcomm.h.

Constructors and Destructors

◆ RUsbOstComm()

RUsbOstComm::RUsbOstComm ( )

Definition at line 88 of file usbostcomm.h.

89 {
90 }

Functions

◆ Close()

TInt RUsbOstComm::Close ( )

Definition at line 143 of file usbostcomm.h.

144 {
145  TInt err = SendReceive(EUsbOstCmdCodeClose);
146  RHandleBase::Close();
147  return err;
148 }

◆ Connect()

TInt RUsbOstComm::Connect ( )

Definition at line 92 of file usbostcomm.h.

93 {
94  _LIT(KUsbOstServerName, "!UsbOstRouter");
95  _LIT(KUsbOstServerImageName, "usbostrouter");
96  const TUid KUsbOstServerUid = { 0x200170BE };
97  TInt startupAttempts = 2;
98  for(;;) {
99  TInt ret = CreateSession(KUsbOstServerName, TVersion(1,0,0));
100  if (ret != KErrNotFound && ret != KErrServerTerminated) {
101  return ret;
102  }
103 
104  if (startupAttempts-- == 0) {
105  return ret;
106  }
107 
108  RProcess server;
109  ret = server.Create(KUsbOstServerImageName, KNullDesC, KUsbOstServerUid);
110  if (ret != KErrNone)
111  return ret;
112 
113  TRequestStatus serverDiedRequestStatus;
114  server.Rendezvous(serverDiedRequestStatus);
115 
116  if (serverDiedRequestStatus != KRequestPending) {
117  // Abort startup
118  server.Kill(KErrNone);
119  } else {
120  // Logon OK - start the server
121  server.Resume();
122  }
123  User::WaitForRequest(serverDiedRequestStatus);
124  ret = (server.ExitType() == EExitPanic) ? KErrGeneral : serverDiedRequestStatus.Int();
125  server.Close();
126 
127  if (ret != KErrNone && ret != KErrAlreadyExists) {
128  return ret;
129  }
130  }
131 }
static QAuServer & server()
Definition: qsound.cpp:79

◆ Disconnect()

TInt RUsbOstComm::Disconnect ( )

Definition at line 133 of file usbostcomm.h.

134 {
135  return SendReceive(EUsbOstCmdDisconnect);
136 }

◆ Open()

TInt RUsbOstComm::Open ( )

Definition at line 138 of file usbostcomm.h.

139 {
140  return SendReceive(EUsbOstCmdCodeOpen);
141 }

◆ ReadCancel()

TInt RUsbOstComm::ReadCancel ( )

Definition at line 162 of file usbostcomm.h.

163 {
164  return SendReceive(EUsbOstCmdCodeReadCancel);
165 }

◆ ReadMessage()

void RUsbOstComm::ReadMessage ( TRequestStatus &  aStatus,
TDes8 &  aDes 
)

Definition at line 156 of file usbostcomm.h.

157 {
158  TIpcArgs args(aDes.MaxLength(), &aDes);
159  SendReceive(EUsbOstCmdCodeReadMsg, args, aStatus);
160 }

◆ RegisterProtocolID()

TInt RUsbOstComm::RegisterProtocolID ( TOstProtIds  aId,
TBool  aNeedHeader 
)

Definition at line 150 of file usbostcomm.h.

151 {
152  TIpcArgs args(aId, aNeedHeader);
153  return SendReceive(EUsbOstCmdCodeRegisterId, args);
154 }

◆ Version()

TVersion RUsbOstComm::Version ( ) const

Definition at line 176 of file usbostcomm.h.

177 {
178  // This function has to go to the DLL, unfortunately
179  TVersion result; // Return 0.0.0 on any error
180  RLibrary lib;
181  TInt err = lib.Load(_L("usbostcomm"));
182  if (err) return result;
183 
184  TLibraryFunction fn = lib.Lookup(KVersionOrdinal);
185  if (fn)
186  result = ((TVersionFunction)fn)(this);
187  lib.Close();
188  return result;
189 }
const TInt KVersionOrdinal
Definition: usbostcomm.h:174
TVersion(* TVersionFunction)(const RUsbOstComm *)
Definition: usbostcomm.h:173

◆ WriteMessage()

void RUsbOstComm::WriteMessage ( TRequestStatus &  aStatus,
const TDesC8 &  aDes,
TBool  aHasHeader = EFalse 
)

Definition at line 167 of file usbostcomm.h.

168 {
169  TIpcArgs args(aHasHeader, aDes.Length(), &aDes);
170  SendReceive(EUsbOstCmdCodeWriteMsg, args, aStatus);
171 }

The documentation for this class was generated from the following file: