datacommsserver/esockserver/csock/CS_RSLV.CPP
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <es_sock.h>
       
    17 #include "CS_STD.H"
       
    18 #include <comms-infras/sockmes.h>
       
    19 #include "es_flog.h"
       
    20 
       
    21 EXPORT_C TInt RHostResolver::Open(RSocketServ &aSocketServer,TUint anAddrFamily,TUint aProtocol)
       
    22 //
       
    23 // set up the sub session
       
    24 //
       
    25 /** Initialises a name resolution service provided by a particular protocol.
       
    26 
       
    27 This must be called before other object functions are used.
       
    28 
       
    29 @param aSocketServer The socket server session 
       
    30 @param anAddrFamily A constant identifying the protocol family 
       
    31 @param aProtocol A constant that identifies the protocol that provides the 
       
    32 name resolution service 
       
    33 @return KErrNone if successful otherwise another of the system-wide error codes. */
       
    34 	{
       
    35 	RSessionBase &s=aSocketServer;
       
    36 	LOG( ESockLog::Printf(_L8("RHostResolver %08x:\tOpen() tid %d"), this, (TUint)RThread().Id()));
       
    37 	return CreateSubSession(s,EHRCreate,TIpcArgs(anAddrFamily,aProtocol));
       
    38 	}
       
    39 
       
    40 EXPORT_C TInt RHostResolver::Open(RSocketServ &aSocketServer,TUint anAddrFamily,TUint aProtocol,RConnection& aConnection)
       
    41 /** Initialises a name resolution service provided by a particular protocol, and associates the service with the same 
       
    42 interface as an existing RConnection instance.
       
    43 
       
    44 This must be called before other object functions are used.
       
    45 
       
    46 Note that the association is instantaneous, in that the Host Resolver is associated with the
       
    47 interface that the RConnection is associated with at the present time.  This association
       
    48 terminates when the underlying interface goes down.
       
    49 
       
    50 @param aServer The socket server session.
       
    51 @param anAddrFamily A constant identifying the protocol family.
       
    52 @param aProtocol A constant that identifies the protocol that provides the name resolution service.
       
    53 @param aConnection Existing RConnection whose interface this Host Resolver will be associated with.
       
    54 @return KErrNone if successful otherwise another of the system-wide error codes.
       
    55  */
       
    56 	{
       
    57 	// passing an RConnection which doesn't belong to the same session is a serious programming error, hence panic.
       
    58 	if (!aConnection.SameSession(aSocketServer.Handle()))
       
    59 		Panic(EBadRConnection);
       
    60 
       
    61 	RSessionBase &s=aSocketServer;
       
    62 	LOG( ESockLog::Printf(_L8("RHostResolver %08x:\tOpen(RConnection %08x) tid %d"), this, &aConnection, (TUint)RThread().Id()));
       
    63 	return CreateSubSession(s,EHRCreateWithConnection,TIpcArgs(anAddrFamily, aProtocol, aConnection.SubSessionHandle()));
       
    64 	}
       
    65 
       
    66 EXPORT_C void RHostResolver::GetByName(const TDesC &aName,TNameEntry &aResult,TRequestStatus &aStatus)
       
    67 //
       
    68 // Get a host by name
       
    69 //
       
    70 /** Resolves a machine name to a TSockAddress asynchronously. 
       
    71 
       
    72 The server will fill in the supplied TNameEntry.
       
    73 
       
    74 @param aName The name to resolve. The format of the name and any wild-cards 
       
    75 supported, along with any separators in hierarchical name systems, are protocol 
       
    76 specific 
       
    77 @param aResult On return, the result of the name resolution. If more than one 
       
    78 result is allowed by the protocol, the client can call Next() to find any 
       
    79 further results. 
       
    80 @param aStatus Indicates asynchronous operation and, on completion, contains 
       
    81 an error code: see the system-wide error codes. */
       
    82 	{
       
    83 	LOG
       
    84 	(
       
    85 		const TInt KBufSize = 32;
       
    86 		TPtrC limitedName(aName.Ptr(), aName.Length() > KBufSize ? KBufSize : aName.Length());
       
    87 		TBuf8<KBufSize> name;
       
    88 		name.Copy(limitedName);
       
    89 
       
    90 		ESockLog::Printf(_L8("RHostResolver %08x:\tGetByName(\"%S\") tid %d"), this, &name, (TUint)RThread().Id());
       
    91 	);
       
    92 	SendReceive(EHRGetByName,TIpcArgs(&aName,&aResult),aStatus);
       
    93 	}
       
    94 
       
    95 EXPORT_C TInt RHostResolver::GetByName(const TDesC &aName,TNameEntry &aResult)
       
    96 //
       
    97 // Get a host by name
       
    98 //
       
    99 /** Resolves a machine name to a TSockAddress.
       
   100 
       
   101 The server will fill in the supplied TNameEntry.
       
   102 
       
   103 @param aName The name to resolve. The format of the name and any wild-cards 
       
   104 supported, along with any separators in hierarchical name systems, are protocol 
       
   105 specific 
       
   106 @param aResult On return, the result of the name resolution. If more than one 
       
   107 result is allowed by the protocol, the client can call Next() to find any 
       
   108 further results.
       
   109 @return KErrNone if successful otherwise another of the system-wide error codes.
       
   110 @capability Dependent on the type of connection so deferred to PRT */
       
   111 	{
       
   112 
       
   113 	TRequestStatus stat;
       
   114 	GetByName(aName,aResult,stat);
       
   115 	User::WaitForRequest(stat);
       
   116 	return stat.Int();
       
   117 	}
       
   118 
       
   119 EXPORT_C void RHostResolver::Next(TNameEntry &aResult,TRequestStatus &aStatus)
       
   120 /**
       
   121 Get the next response if there is more than one response for a given host name (alias list)
       
   122 
       
   123 Returns the next answer asynchronously, where there is more than one response
       
   124 for a given host name. 
       
   125 
       
   126 For some protocols, GetByName() and GetByAddress() may find more than one answer, 
       
   127 for example if aliases are allowed. 
       
   128 
       
   129 @param aResult Returns the next result of the name resolution. 
       
   130 @param aStatus Indicates asynchronous operation and on completion contains 
       
   131 an error code: see the system-wide error codes. */
       
   132 	{
       
   133 	SendReceive(EHRNext,TIpcArgs(0,&aResult),aStatus); //Question - is the change is right?
       
   134 	}
       
   135 
       
   136 EXPORT_C TInt RHostResolver::Next(TNameEntry &aResult)
       
   137 /**
       
   138 Get the next response if there is more than one response for a given host name (alias list)
       
   139 
       
   140 
       
   141 
       
   142 Returns the next answer where there is more than one response for a given host name. 
       
   143 
       
   144 For some protocols, GetByName() and GetByAddress() may find more than one answer, 
       
   145 for example if aliases are allowed. 
       
   146 
       
   147 @param aResult Returns the next result of the name resolution. 
       
   148 @return KErrNone if successful otherwise another of the system-wide error codes. */
       
   149 	{
       
   150 	
       
   151 	TRequestStatus stat;
       
   152 	Next(aResult,stat);
       
   153 	User::WaitForRequest(stat);
       
   154 	return stat.Int();
       
   155 	}
       
   156 
       
   157 EXPORT_C void RHostResolver::GetByAddress(const TSockAddr &anAddr,TNameEntry &aResult,TRequestStatus &aStatus)
       
   158 /**
       
   159 Get host by address (as get by name)
       
   160 
       
   161 Gets the name of a host from its address asynchronously
       
   162 
       
   163 
       
   164 @param anAddr The address to use 
       
   165 @param aResult On return, the result of the query. If more than one result 
       
   166 is allowed by the protocol, the client can call Next() to find any further 
       
   167 results. 
       
   168 @param aStatus Indicates asynchronous operation and on completion contains 
       
   169 an error code: see the system-wide error codes.
       
   170 @capability Dependent on the type of connection so deferred to PRT  */
       
   171 	{
       
   172 	SendReceive(EHRGetByAddress,TIpcArgs(&anAddr,&aResult),aStatus);
       
   173 	}
       
   174 
       
   175 EXPORT_C TInt RHostResolver::GetByAddress(const TSockAddr &anAddr,TNameEntry &aResult)
       
   176 /**
       
   177 Get host by address (as get by name)
       
   178 
       
   179 Gets the name of a host from its address 
       
   180 
       
   181 @param anAddr The address to use 
       
   182 @param aResult Returns the result of the query. If more than one result is 
       
   183 allowed by the protocol, the client can call Next() to find any further results. 
       
   184 
       
   185 @return KErrNone if successful otherwise another of the system-wide error codes.
       
   186 @capability Dependent on the type of connection so deferred to PRT */
       
   187 	{
       
   188 	
       
   189 	TRequestStatus stat;
       
   190 	GetByAddress(anAddr,aResult,stat);
       
   191 	User::WaitForRequest(stat);
       
   192 	return stat.Int();
       
   193 	}
       
   194 
       
   195 EXPORT_C TInt RHostResolver::GetHostName(TDes &aName)
       
   196 /**
       
   197 
       
   198 
       
   199 Gets the name of the local host.
       
   200 
       
   201 Note that with some protocols the name of the local host is not necessarily 
       
   202 known at all times. In some cases, a preceding call to SetHostName() must 
       
   203 have been made.
       
   204 
       
   205 @param aName Returns the result of the query. The buffer passed in should 
       
   206 have a minimum length of 256 characters, otherwise a panic may occur: you 
       
   207 can use a parameter of the THostName type. 
       
   208 @return KErrNone if successful otherwise another of the system-wide error codes.
       
   209 @capability Dependent on the type of connection so deferred to PRT */
       
   210 	{
       
   211 	return SendReceive(EHRGetHostName,TIpcArgs(&aName));
       
   212 	}
       
   213 
       
   214 EXPORT_C void RHostResolver::GetHostName(TDes &aName,TRequestStatus &aStatus)
       
   215 /** Gets the name of the local host asynchronously.
       
   216 
       
   217 Note that with some protocols the name of the local host is not necessarily 
       
   218 known at all times. In some cases, a preceding call to SetHostName() must 
       
   219 have been made.
       
   220 
       
   221 @param aName Returns the result of the query. The buffer passed in should 
       
   222 have a minimum length of 256 characters, otherwise a panic may occur: you 
       
   223 can use a parameter of the THostName type. 
       
   224 @param aStatus Indicates asynchronous operation and on completion contains 
       
   225 an error code: see the system-wide error codes.
       
   226 @capability Dependent on the type of connection so deferred to PRT */
       
   227 	{
       
   228 	SendReceive(EHRGetHostName,TIpcArgs(&aName),aStatus);
       
   229 	}
       
   230 
       
   231 EXPORT_C TInt RHostResolver::SetHostName(const TDesC &aName)
       
   232 /** Sets the name of the local host.
       
   233 @param aName The local host name.
       
   234 @return KErrNone if successful, otherwise another of the system-wide
       
   235 error codes. 
       
   236 @capability NetworkControl Service restricting and stored at protocol level
       
   237 */
       
   238 	{
       
   239 	return SendReceive(EHRSetHostName,TIpcArgs(&aName));
       
   240 	}
       
   241 
       
   242 
       
   243 EXPORT_C TInt RHostResolver::SetOpt(TUint anOptionName,TUint anOptionLevel,const TDesC8& anOption)
       
   244 	{
       
   245 	LOG( ESockLog::Printf(_L8("RHostResolver %08x:\tSetOpt() tid %d"), this, (TUint)RThread().Id()));
       
   246 	return SendReceive(EHRSetOpt,TIpcArgs(anOptionName,&anOption,anOptionLevel));
       
   247 	}
       
   248 
       
   249 
       
   250 EXPORT_C void RHostResolver::Cancel()
       
   251 /** Cancels any outstanding asynchronous calls, which will return with error code 
       
   252 KErrCancel. */
       
   253 	{
       
   254 	SendReceive(EHRCancel,TIpcArgs());
       
   255 	}
       
   256 
       
   257 EXPORT_C void  RHostResolver::Close()
       
   258 /**
       
   259 
       
   260 
       
   261 Closes a name resolution service. If a service has been opened using Open(), 
       
   262 then it should be closed using Close(). This will ensure all associated resources 
       
   263 are released. */
       
   264 	{
       
   265 	LOG( ESockLog::Printf(_L8("RHostResolver %08x:\tClose() tid %d"), this, (TUint)RThread().Id()));
       
   266 
       
   267 	CloseSubSession(EHRClose);
       
   268 	}
       
   269 
       
   270 
       
   271 
       
   272 EXPORT_C void RHostResolver::Query(const TDesC8& aQuery, TDes8& aResult, TRequestStatus& aStatus)
       
   273 /**
       
   274 *   Protocol - independent query. Asynchronous version.
       
   275 *
       
   276 *   @param  aQuery      contains query data. The concrete type of the data depends on protocol.
       
   277 *                       e.g. for tcpip it will imply DNS query.
       
   278 *   @param  aResult     Descriptor that will receive data. The concrete meaning of this data depends on protocol. 
       
   279 *   @param  aStatus     indicates asynchronous operation, on completion contains a system-wide error code
       
   280 *	@capability 		Dependent on the type of connection so deferred to PRT 
       
   281 */
       
   282 {
       
   283     LOG( ESockLog::Printf(_L8("RHostResolver %08x:\tQuery() tid %d"), this, (TUint)RThread().Id()));
       
   284     
       
   285 	SendReceive(EHrQuery,TIpcArgs(&aQuery, &aResult),aStatus);
       
   286 }
       
   287 
       
   288 EXPORT_C TInt RHostResolver::Query(const TDesC8& aQuery, TDes8& aResult)
       
   289 /**
       
   290 
       
   291 Protocol - independent query. Synchronous version.
       
   292 
       
   293 @param  aQuery      contains query data. The concrete type of the data depends on protocol.
       
   294                    e.g. for tcpip it will imply DNS query.
       
   295 @param  aResult     Descriptor that will receive data. The concrete meaning of this data depends on protocol. 
       
   296 @return             system-wide error code.
       
   297 @capability 		Dependent on the type of connection so deferred to PRT 
       
   298 */
       
   299 	{
       
   300 	TRequestStatus stat;
       
   301 	Query(aQuery,aResult,stat);
       
   302 	User::WaitForRequest(stat);
       
   303 
       
   304 	return stat.Int();
       
   305 	}
       
   306 
       
   307 EXPORT_C void RHostResolver::QueryGetNext(TDes8& aResult, TRequestStatus& aStatus)
       
   308 /**
       
   309 
       
   310 Get the next query result. For some queries there can be more than one results. Asynchronous version.
       
   311 
       
   312 @param  aResult     Descriptor that will receive data. The concrete meaning of this data depends on protocol. 
       
   313 @param  aStatus     indicates asynchronous operation, on completion contains a system-wide error code.
       
   314                    In particular KErrNotFound means that there is no more information from resolver.
       
   315 */
       
   316 {
       
   317     LOG( ESockLog::Printf(_L8("RHostResolver %08x:\tQueryGetNext() tid %d"), this, (TUint)RThread().Id()));
       
   318 
       
   319 	SendReceive(EHrQueryNext,TIpcArgs(&aResult),aStatus);
       
   320 
       
   321 }
       
   322 
       
   323 EXPORT_C TInt RHostResolver::QueryGetNext(TDes8& aResult)
       
   324 /**
       
   325 
       
   326 Get the next query result. For some queries there can be more than one results. Synchronous version.
       
   327 
       
   328 @param  aResult     Descriptor that will receive data. The concrete meaning of this data depends on protocol. 
       
   329 @return             system-wide error code. In particular KErrNotFound means that there is no more information from resolver.
       
   330 */
       
   331 	{
       
   332 	TRequestStatus stat;
       
   333 	QueryGetNext(aResult,stat);
       
   334 	User::WaitForRequest(stat);
       
   335 
       
   336 	return stat.Int();
       
   337 	}
       
   338 
       
   339 EXPORT_C TInt RServiceResolver::Open(RSocketServ &aSocketServer,TUint anAddrFamily,TUint aSocketType,TUint aProtocol)
       
   340 /**
       
   341 set up the sub session - unlike name resolvers and net databases, services can be socket type specific.
       
   342 Opens a service resolver service. 
       
   343 
       
   344 Unlike name resolvers (RHostResolver) and net databases (RNetDatabase), services can be socket type specific.
       
   345 
       
   346 @param aSocketServer The socket server session.
       
   347 @param anAddrFamily A constant identifying the protocol family.
       
   348 @param aSocketType A constant that identifies the socket type.
       
   349 @param aProtocol A constant that identifies the protocol that provides the 
       
   350 service.
       
   351 @return KErrNone if successful otherwise another of the system-wide error codes. */
       
   352 	{
       
   353 	RSessionBase &s=aSocketServer;
       
   354 	return CreateSubSession(s,ESRCreate,TIpcArgs(anAddrFamily,aSocketType,aProtocol));
       
   355 	}
       
   356 
       
   357 EXPORT_C void RServiceResolver::GetByName(const TDesC &aName,TPortNum &aPort,TRequestStatus &aStatus)
       
   358 /** Gets a service by name asynchronously.
       
   359 
       
   360 @param aName Name of the service to get.
       
   361 @param aPort On completion, the port associated with the service.
       
   362 @param aStatus On completion, KErrNone if successful otherwise another of the 
       
   363 system-wide error codes. */
       
   364 	{
       
   365 	SendReceive(ESRGetByName,TIpcArgs(&aName,&aPort),aStatus);
       
   366 	}
       
   367 
       
   368 EXPORT_C TInt RServiceResolver::GetByName(const TDesC &aName,TPortNum &aPort)
       
   369 /**
       
   370 Get a service by name.
       
   371 
       
   372 @param aName Name of the service to get.
       
   373 @param aPort On return, the port associated with the service.
       
   374 @return KErrNone if successful otherwise another of the system-wide error codes. */
       
   375 	{
       
   376 	
       
   377 	TRequestStatus stat;
       
   378 	GetByName(aName,aPort,stat);
       
   379 	User::WaitForRequest(stat);
       
   380 	return stat.Int();
       
   381 	}
       
   382 
       
   383 EXPORT_C void RServiceResolver::GetByNumber(const TUint aPort,TDes &aName,TRequestStatus &aStatus)
       
   384 /** Gets the name of the service asynchronously.
       
   385 
       
   386 @param aPort Port of the service.
       
   387 @param aName On completion, the name of the service.
       
   388 @param aStatus On completion, KErrNone if successful otherwise another of the 
       
   389 system-wide error codes. */
       
   390 	{
       
   391 	SendReceive(ESRGetByNumber,TIpcArgs(&aName,aPort),aStatus);
       
   392 	}
       
   393 
       
   394 EXPORT_C TInt RServiceResolver::GetByNumber(const TUint aPort,TDes &aName)
       
   395 /** Gets the name of the service
       
   396 
       
   397 @param aPort Port of the service.
       
   398 @param aName On return, the name of the service.
       
   399 @return KErrNone if successful otherwise another of the system-wide error codes. */
       
   400 	{
       
   401 
       
   402 	TRequestStatus stat;
       
   403 	GetByNumber(aPort,aName,stat);
       
   404 	User::WaitForRequest(stat);
       
   405 	return stat.Int();
       
   406 	}
       
   407 
       
   408 EXPORT_C void RServiceResolver::RegisterService(const TDesC &aName,const TUint &aPort,TRequestStatus &aStatus)
       
   409 /** Registers a new service asynchronously.
       
   410 
       
   411 @param aName Name of the service.
       
   412 @param aPort Port of the service.
       
   413 @param aStatus On completion, KErrNone if successful otherwise another of the 
       
   414 system-wide error codes. 
       
   415 @capability NetworkControl To protect against dangerous new services being added, which may steal legimate services resources */
       
   416 	{
       
   417 	SendReceive(ESRRegisterService,TIpcArgs(&aName,aPort),aStatus);
       
   418 	}
       
   419 
       
   420 EXPORT_C TInt RServiceResolver::RegisterService(const TDesC &aName,const TUint &aPort)
       
   421 /** Registers a new service.
       
   422 
       
   423 @param aName Name of the service.
       
   424 @param aPort Port of the service.
       
   425 @return KErrNone if successful, otherwise another of the system-wide error codes.
       
   426 @capability NetworkControl To protect against dangerous new services being added, which may steal legimate services resources */
       
   427 	{
       
   428 
       
   429 	TRequestStatus stat;
       
   430 	RegisterService(aName,aPort,stat);
       
   431 	User::WaitForRequest(stat);
       
   432 	return stat.Int();
       
   433 	}
       
   434 
       
   435 EXPORT_C void RServiceResolver::RemoveService(const TDesC &aName,const TUint &aPort,TRequestStatus &aStatus)
       
   436 /** Removes a service asynchronously.
       
   437 
       
   438 @param aName Name of the service to remove.
       
   439 @param aPort Port of the service to remove.
       
   440 @param aStatus On completion, KErrNone if successful otherwise another of the 
       
   441 system-wide error codes. 
       
   442 @capability NetworkControl Ensure that only privileged apps can remove information from the service resolver */
       
   443 	{
       
   444 	SendReceive(ESRRemoveService,TIpcArgs(&aName,aPort),aStatus);
       
   445 	}
       
   446 
       
   447 
       
   448 EXPORT_C TInt RServiceResolver::RemoveService(const TDesC &aName,const TUint &aPort)
       
   449 /** Removes a service.
       
   450 
       
   451 @param aName Name of the service.
       
   452 @param aPort Port of the service.
       
   453 @return KErrNone if successful otherwise another of the system-wide error codes.
       
   454 @capability NetworkControl Ensure that only privileged apps can remove information from the service resolver */
       
   455 	{
       
   456 
       
   457 	TRequestStatus stat;
       
   458 	RemoveService(aName,aPort,stat);
       
   459 	User::WaitForRequest(stat);
       
   460 	return stat.Int();
       
   461 	}
       
   462 
       
   463 EXPORT_C void RServiceResolver::Cancel()
       
   464 /** Cancels any pending request. */
       
   465 	{
       
   466 	SendReceive(ESRCancel,TIpcArgs());
       
   467 	}
       
   468 
       
   469 EXPORT_C void RServiceResolver::Close()
       
   470 /**
       
   471 Closes a service resolver service
       
   472 
       
   473 If a service has been opened using Open(), 
       
   474 then it should be closed using Close(). This will ensure all associated resources 
       
   475 are released. */
       
   476 	{
       
   477 
       
   478 	CloseSubSession(ESRClose);
       
   479 	}
       
   480 
       
   481 EXPORT_C TInt RNetDatabase::Open(RSocketServ &aSocketServer,TUint anAddrFamily,TUint aProtocol)
       
   482 //
       
   483 // set up the sub session
       
   484 //
       
   485 /** Initialises a database access service provided by a particular protocol. It 
       
   486 must be called before other object functions are used.
       
   487 
       
   488 @param aSocketServer The socket server session 
       
   489 @param anAddrFamily A constant identifying the protocol family 
       
   490 @param aProtocol A constant that identifies the protocol that provides the 
       
   491 database access service 
       
   492 @return KErrNone if successful otherwise another of the system-wide error codes. */
       
   493 	{
       
   494 	RSessionBase &s=aSocketServer;
       
   495 	return CreateSubSession(s,ENDCreate,TIpcArgs(anAddrFamily,aProtocol));
       
   496 	}
       
   497 
       
   498 EXPORT_C void RNetDatabase::Query(const TDesC8 &aQuery,TDes8 &aResult,TRequestStatus &aStat)
       
   499 /** Makes a query to the database asynchronously.
       
   500 
       
   501 @param aQuery The query to perform 
       
   502 @param aResult The result of the query 
       
   503 @param aStat Indicates asynchronous operation and on completion contains an 
       
   504 error code: see the system-wide error codes.
       
   505 @capability Dependent on the type of connection so deferred to PRT */
       
   506 	{
       
   507 	SendReceive(ENDQuery,TIpcArgs(&aQuery,Max(aQuery.Length(),aResult.Length()),&aResult),aStat);
       
   508 	}
       
   509 
       
   510 EXPORT_C TInt RNetDatabase::Query(const TDesC8 &aQuery,TDes8 &aResult)
       
   511 //
       
   512 // unfortunately this API must be so general.
       
   513 //
       
   514 /** Makes a query to the database.
       
   515 
       
   516 @param aQuery The query to perform 
       
   517 @param aResult The result of the query 
       
   518 @return KErrNone if successful otherwise another of the system-wide error codes.
       
   519 @capability Dependent on the type of connection so deferred to PRT */
       
   520 	{
       
   521 
       
   522 	TRequestStatus stat;
       
   523 	Query(aQuery,aResult,stat);
       
   524 	User::WaitForRequest(stat);
       
   525 	return stat.Int();
       
   526 	}
       
   527 
       
   528 EXPORT_C void RNetDatabase::Add(const TDesC8& anItem,TRequestStatus& aStat)
       
   529 /** Adds a record to the database asynchronously.
       
   530 
       
   531 @param anItem The record to add 
       
   532 @param aStat Indicates asynchronous operation and on completion contains an 
       
   533 error code: see the system-wide error codes.
       
   534 @capability Dependent on the type of connection so deferred to PRT */
       
   535 	{
       
   536 	SendReceive(ENDAdd,TIpcArgs(&anItem,anItem.Length()),aStat);
       
   537 	}
       
   538 
       
   539 EXPORT_C TInt RNetDatabase::Add(const TDesC8& anItem)
       
   540 /** Adds a record to the database.
       
   541 
       
   542 @param anItem The record to add 
       
   543 @return KErrNone if successful otherwise another of the system-wide error codes.
       
   544 @capability Dependent on the type of connection so deferred to PRT  */
       
   545 	{
       
   546 	TRequestStatus stat;
       
   547 	Add(anItem,stat);
       
   548 	User::WaitForRequest(stat);
       
   549 	return stat.Int();
       
   550 	}
       
   551 
       
   552 EXPORT_C void RNetDatabase::Remove(const TDesC8& anItem,TRequestStatus& aStat)
       
   553 /** Removes a record from the database asynchronously.
       
   554 
       
   555 @param anItem The record to remove 
       
   556 @param aStat Indicates asynchronous operation and on completion contains an 
       
   557 error code: see the system-wide error codes.
       
   558 @capability Dependent on the type of connection so deferred to PRT  */
       
   559 	{
       
   560 	SendReceive(ENDRemove,TIpcArgs(&anItem,anItem.Length()),aStat);
       
   561 	}
       
   562 
       
   563 EXPORT_C TInt RNetDatabase::Remove(const TDesC8& anItem)
       
   564 /** Removes a record from the database.
       
   565 
       
   566 @param anItem The record to remove 
       
   567 @return KErrNone if successful otherwise another of the system-wide error codes.
       
   568 @capability Dependent on the type of connection so deferred to PRT  */
       
   569 	{
       
   570 	TRequestStatus stat;
       
   571 	Remove(anItem,stat);
       
   572 	User::WaitForRequest(stat);
       
   573 	return stat.Int();
       
   574 	}
       
   575 
       
   576 EXPORT_C void RNetDatabase::Cancel()
       
   577 /** Cancels any outstanding asynchronous calls, which will return with error code 
       
   578 KErrCancel. */
       
   579 	{
       
   580 	SendReceive(ENDCancel,TIpcArgs());
       
   581 	}
       
   582 
       
   583 EXPORT_C void RNetDatabase::Close()
       
   584 /** Closes a database access service. If a service has been opened using Open(), 
       
   585 then it should be closed using Close(). This will ensure all associated resources 
       
   586 are released. */
       
   587 	{
       
   588 	CloseSubSession(ENDClose);
       
   589 	}
       
   590