DirectPrint/DirectPrintClient/src/directprintclient.cpp
branchRCL_3
changeset 11 613a5ff70823
child 19 2275db202402
equal deleted inserted replaced
10:3f1fec088555 11:613a5ff70823
       
     1 /*
       
     2 * Copyright (c) 2010 Kanrikogaku Kenkyusho, Ltd.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "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 * Kanrikogaku Kenkyusho, Ltd. - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32svr.h>
       
    20 #include <e32math.h>
       
    21 
       
    22 #include "directprintclient.h"
       
    23 #include "directprintclientserver.h"
       
    24 #include "directprintcapability.h"
       
    25 #include "clog.h"
       
    26 #include "directprintjobguarddata.h"
       
    27 
       
    28 namespace
       
    29 	{	
       
    30 	// Server startup code
       
    31 	TInt StartServer()
       
    32 		{
       
    33 		// EPOC and EKA2 is easy, we just create a new server process. Simultaneous
       
    34 		// launching of two such processes should be detected when the second one
       
    35 		// attempts to create the server object, failing with KErrAlreadyExists.
       
    36 		RProcess server;
       
    37 		TInt r = server.Create( KDirectPrintServerImg, KNullDesC );
       
    38 
       
    39 		if( r != KErrNone )
       
    40 			return r;
       
    41 		TRequestStatus stat;
       
    42 		server.Rendezvous(stat);
       
    43 		if (stat!=KRequestPending)
       
    44 			server.Kill(0);		// abort startup
       
    45 		else
       
    46 			server.Resume();	// logon OK - start the server
       
    47 		User::WaitForRequest(stat);		// wait for start or death
       
    48 		// we can't use the 'exit reason' if the server panicked as this
       
    49 		// is the panic 'reason' and may be '0' which cannot be distinguished
       
    50 		// from KErrNone
       
    51 		r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
       
    52 
       
    53 		server.Close();
       
    54 		return r;
       
    55 		}
       
    56 	}
       
    57 
       
    58 TVersion RDirectPrintClient::Version() const
       
    59 	{
       
    60 	return TVersion( KDirectPrintServerMajor, KDirectPrintServerMinor, KDirectPrintServerBuild );
       
    61 	}
       
    62 
       
    63 EXPORT_C RDirectPrintClient::RDirectPrintClient()
       
    64 	: RSessionBase()
       
    65 	, iDicsoveryDataPtr(NULL, 0, 0)
       
    66 	, iIdleDataPtr(NULL, 0, 0)
       
    67 	, iJobDataPtr(NULL, 0, 0)
       
    68 	, iNameDataPtr(NULL, 0, 0)
       
    69     {
       
    70     iCapability = NULL;
       
    71     }
       
    72 
       
    73 EXPORT_C void RDirectPrintClient::ConnectL()
       
    74 	{
       
    75 	LOG1("RDirectPrintClient::Connect Handle(): %d", Handle());
       
    76 	// check against double-connect
       
    77 	if( Handle() != KNullHandle )
       
    78 		{
       
    79 		User::Leave(KErrAlreadyExists);
       
    80 		}
       
    81 
       
    82 	iCapability = new (ELeave) TDirectPrintCapability();
       
    83 
       
    84 	// create process
       
    85 	TInt err = StartServer();
       
    86 	if (err == KErrNone)
       
    87 		{
       
    88 		// create session
       
    89 		err = CreateSession( KDirectPrintServerName, Version() );
       
    90 		}
       
    91 	User::LeaveIfError(err);
       
    92 	}
       
    93 
       
    94 EXPORT_C void RDirectPrintClient::Close()
       
    95 	{
       
    96 	LOG("RDirectPrintClient::Close begin");
       
    97 	if( iCapability )
       
    98 		{		
       
    99 		delete iCapability;
       
   100 		iCapability = NULL;	
       
   101 		}	
       
   102 	RSessionBase::Close();
       
   103 	LOG("RDirectPrintClient::Close end");
       
   104 	}
       
   105 
       
   106 EXPORT_C TInt RDirectPrintClient::CountConnections( TInt& aConnections ) const
       
   107 	{
       
   108 	TPckg<TInt> connsBuf( aConnections );	
       
   109 	return SendReceive( ECountConnections, TIpcArgs( &connsBuf ) );
       
   110 	}
       
   111 
       
   112 EXPORT_C TInt RDirectPrintClient::SetForeground( TInt aFg ) const
       
   113 	{
       
   114 	return SendReceive( ESetForeground, TIpcArgs( aFg ) );
       
   115 	}
       
   116 
       
   117 EXPORT_C TInt RDirectPrintClient::ReserveEngine() const
       
   118 	{
       
   119 	return SendReceive( EReserveEngine );
       
   120 	}
       
   121 
       
   122 EXPORT_C TInt RDirectPrintClient::ReleaseEngine() const
       
   123 	{
       
   124 	return SendReceive( EReleaseEngine );
       
   125 	}
       
   126 
       
   127 EXPORT_C TInt RDirectPrintClient::SupportedProtocols() const
       
   128 	{
       
   129 	LOG("RDirectPrintClient::SupportedProtocols ESupportedProtocols");
       
   130 	TInt prots = SendReceive( ESupportedProtocols );
       
   131 	LOG1("RDirectPrintClient::SupportedProtocols end with: %d", prots);
       
   132 	return prots;
       
   133 	}
       
   134 
       
   135 EXPORT_C TInt RDirectPrintClient::GetNumPrintPages() const
       
   136 	{
       
   137 	LOG("RDirectPrintClient::GetNumPrintPages EGetNumPrintPages");
       
   138 	TInt pages = SendReceive( EGetNumPrintPages );
       
   139 	LOG1("RDirectPrintClient::GetNumPrintPages end with: %d", pages);
       
   140 	return pages;	
       
   141 	}
       
   142 
       
   143 EXPORT_C TInt RDirectPrintClient::GetJobStatus() const
       
   144 	{
       
   145 	LOG("RDirectPrintClient::GetJobStatus EGetJobStatus");
       
   146 	TInt status = SendReceive( EGetJobStatus );
       
   147 	LOG1("RDirectPrintClient::GetJobStatus end with: %d", status);
       
   148 	return status;
       
   149 	}
       
   150 
       
   151 EXPORT_C TInt RDirectPrintClient::GetPrinterStatus( TInt aPrinterID ) const
       
   152 	{
       
   153 	LOG1("RDirectPrintClient::GetPrinterStatus EGetPrinterStatus aPrinterID: %d", aPrinterID);
       
   154 	TInt status = SendReceive( EGetPrinterStatus, TIpcArgs( aPrinterID ) );
       
   155 	LOG1("RDirectPrintClient::GetPrinterStatus end with: %d", status);	
       
   156 	return status;
       
   157 	}
       
   158 
       
   159 EXPORT_C TInt RDirectPrintClient::CancelDiscovery() const
       
   160 	{
       
   161 	LOG("RDirectPrintClient::CancelDiscovery ECancelDiscovery");
       
   162 	TInt err = SendReceive( ECancelDiscovery );
       
   163 	LOG1("RDirectPrintClient::CancelDiscovery end with: %d", err);
       
   164 	return err;
       
   165 	}
       
   166 
       
   167 EXPORT_C TInt RDirectPrintClient::SubmitPrintJob() const
       
   168 	{
       
   169 	LOG("RDirectPrintClient::SubmitPrintJob ESubmitPrintJob");
       
   170 	TInt err = SendReceive( ESubmitPrintJob );
       
   171 	LOG1("RDirectPrintClient::SubmitPrintJob end with: %d", err);
       
   172 	return err;
       
   173 	}
       
   174 
       
   175 EXPORT_C TInt RDirectPrintClient::CancelPrintJob() const
       
   176 	{
       
   177 	LOG("RDirectPrintClient::CancelPrintJob ECancelPrintJob");
       
   178 	TInt err = SendReceive( ECancelPrintJob );
       
   179 	LOG1("RDirectPrintClient::CancelPrintJob end with: %d", err);
       
   180 	return err;
       
   181 	}
       
   182 
       
   183 EXPORT_C TInt RDirectPrintClient::ContinuePrintJob() const
       
   184 	{
       
   185 	LOG("RDirectPrintClient::ContinuePrintJob EContinuePrintJob");
       
   186 	TInt err = SendReceive( EContinuePrintJob );
       
   187 	LOG1("RDirectPrintClient::ContinuePrintJob end with: %d", err);
       
   188 	return err;
       
   189 	}
       
   190 
       
   191 EXPORT_C TInt RDirectPrintClient::RemoveCachedPrinter( TInt aPrinterID ) const
       
   192 	{
       
   193 	LOG1("RDirectPrintClient::RemoveCachedPrinter ERemoveCachedPrinter aPrinterID: %d", aPrinterID);
       
   194 	TInt err = SendReceive( ERemoveCachedPrinter, TIpcArgs( aPrinterID ) );	
       
   195 	LOG1("RDirectPrintClient::RemoveCachedPrinter end with: %d", err);
       
   196 	return err;
       
   197 	}
       
   198 
       
   199 EXPORT_C TInt RDirectPrintClient::GetJobTemplateIcon( TInt aTemplateID, TInt& aFbsBitmapHandle ) const
       
   200 	{
       
   201 	TPckg<TInt> handleBuf( aFbsBitmapHandle );
       
   202 	LOG1("RDirectPrintClient::GetJobTemplateIcon EGetJobTemplateIcon aTemplateID: %d", aTemplateID);
       
   203 	TInt err = SendReceive( EGetJobTemplateIcon, TIpcArgs( aTemplateID, &handleBuf ) );
       
   204 	LOG1("RDirectPrintClient::GetJobTemplateIcon aFbsBitmapHandle: %d", aFbsBitmapHandle);
       
   205 	LOG1("RDirectPrintClient::GetJobTemplateIcon end with: %d", err);
       
   206 	return err;
       
   207 	}
       
   208 
       
   209 EXPORT_C TInt RDirectPrintClient::GetNumPreviewPages() const
       
   210 	{
       
   211 	LOG("RDirectPrintClient::GetNumPreviewPages EGetNumPreviewPages");
       
   212 	TInt pages = SendReceive( EGetNumPreviewPages );
       
   213 	LOG1("RDirectPrintClient::GetNumPreviewPages end with: %d", pages);	
       
   214 	return pages;
       
   215 	}
       
   216 
       
   217 EXPORT_C TInt RDirectPrintClient::SetJobSetting( TInt aCapabilityID, TInt aValue, TInt& aAffectedCapability ) const
       
   218 	{
       
   219 	TPckg<TInt> capBuf( aAffectedCapability );
       
   220 	LOG1("RDirectPrintClient::SetJobSetting ESetJobSetting aCapabilityID: %d", aCapabilityID);
       
   221 	LOG1("RDirectPrintClient::SetJobSetting ESetJobSetting aValue: %d", aValue);
       
   222 	TInt err = SendReceive( ESetJobSetting, TIpcArgs( aCapabilityID, aValue, &capBuf ) );
       
   223 	LOG1("RDirectPrintClient::SetJobSetting aAffectedCapability: %d", aAffectedCapability);
       
   224 	LOG1("RDirectPrintClient::SetJobSetting end with: %d", err);
       
   225 	return err;
       
   226 	}
       
   227 
       
   228 EXPORT_C TInt RDirectPrintClient::GetJobSetting( TInt aCapabilityID, TInt& aValue ) const
       
   229 	{
       
   230 	TPckg<TInt> valueBuf( aValue );
       
   231 	LOG1("RDirectPrintClient::GetJobSetting EGetJobSetting aCapabilityID: %d", aCapabilityID);
       
   232 	TInt err = SendReceive( EGetJobSetting, TIpcArgs( aCapabilityID, &valueBuf ) );
       
   233 	LOG1("RDirectPrintClient::GetJobSetting aValue: %d", aValue);
       
   234 	LOG1("RDirectPrintClient::GetJobSetting end with: %d", err);
       
   235 	return err;
       
   236 	}
       
   237 
       
   238 EXPORT_C TInt RDirectPrintClient::GetPrinterCapability(TInt aPrinterID, TInt aCapabilityID, TDirectPrintCapability& aCapability) const
       
   239 	{
       
   240 	LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapability aPrinterID: %d", aPrinterID);
       
   241 	LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapability aCapabilityID: %d", aCapabilityID);
       
   242 	TInt err = SendReceive( EGetPrinterCapability, TIpcArgs( aPrinterID, aCapabilityID ) );
       
   243 	LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapability err: %d", err);
       
   244 
       
   245 	if( !err )
       
   246 		{
       
   247 		TInt capId;
       
   248 		TPckg<TInt> capIdBuf( capId );
       
   249 		LOG("RDirectPrintClient::GetPrinterCapability EGetPrinterCapId");
       
   250 		err = SendReceive( EGetPrinterCapId, TIpcArgs( &capIdBuf ) );
       
   251 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapId err: %d", err);
       
   252 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapId capId: %d", capId);
       
   253 		if( !err )
       
   254 			{
       
   255 			iCapability->iCapabilityID = capId;
       
   256 			}
       
   257 		}
       
   258 
       
   259 	if( !err )
       
   260 		{
       
   261 		TInt type;
       
   262 		TPckg<TInt> typeBuf( type );
       
   263 		LOG("RDirectPrintClient::GetPrinterCapability EGetPrinterCapType");
       
   264 		err = SendReceive( EGetPrinterCapType, TIpcArgs( &typeBuf ) );
       
   265 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapType err: %d", err);
       
   266 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapType type: %d", type);
       
   267 		if( !err )
       
   268 			{
       
   269 			iCapability->iType = static_cast<TDirectPrintCapability::ECapType>(type);
       
   270 			}
       
   271 		}
       
   272 
       
   273 	if( !err )
       
   274 		{
       
   275 		TInt def;
       
   276 		TPckg<TInt> defBuf( def );
       
   277 		LOG("RDirectPrintClient::GetPrinterCapability EGetPrinterCapDef");
       
   278 		err = SendReceive( EGetPrinterCapDef, TIpcArgs( &defBuf ) );
       
   279 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapDef err: %d", err);
       
   280 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapDef def: %d", def);
       
   281 		if( !err )
       
   282 			{
       
   283 			iCapability->iDefaultValue = def;
       
   284 			}
       
   285 		}
       
   286 
       
   287 	if( !err )
       
   288 		{
       
   289 		TInt low;
       
   290 		TPckg<TInt> lowBuf( low );
       
   291 		LOG("RDirectPrintClient::GetPrinterCapability EGetPrinterCapLow");
       
   292 		err = SendReceive( EGetPrinterCapLow, TIpcArgs( &lowBuf ) );
       
   293 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapLow err: %d", err);
       
   294 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapLow low: %d", low);
       
   295 		if( !err )
       
   296 			{
       
   297 			iCapability->iLow = low;
       
   298 			}
       
   299 		}
       
   300 
       
   301 	if( !err )
       
   302 		{
       
   303 		TInt high;
       
   304 		TPckg<TInt> highBuf( high );
       
   305 		LOG("RDirectPrintClient::GetPrinterCapability EGetPrinterCapHigh");
       
   306 		err = SendReceive( EGetPrinterCapHigh, TIpcArgs( &highBuf ) );
       
   307 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapHigh err: %d", err);
       
   308 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapHigh high: %d", high);
       
   309 		if( !err )
       
   310 			{
       
   311 			iCapability->iHigh = high;
       
   312 			}
       
   313 		}
       
   314 
       
   315 	if( !err )
       
   316 		{
       
   317 		TInt count;
       
   318 		TPckg<TInt> countBuf( count );
       
   319 		LOG("RDirectPrintClient::GetPrinterCapability EGetPrinterCapEnumCount");
       
   320 		err = SendReceive( EGetPrinterCapEnumCount, TIpcArgs( &countBuf ) );
       
   321 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapEnumCount err: %d", err);
       
   322 		LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapEnumCount count: %d", count);
       
   323 		
       
   324 		if( !err )
       
   325 			{
       
   326 			iCapability->iEnumCount = count;
       
   327 			for( TInt i = 0; i < count && ! err; i++ )
       
   328 				{
       
   329 				TInt value;
       
   330 				TPckg<TInt> valueBuf( value );
       
   331 				LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapEnum i: %d",i);
       
   332 				TInt err = SendReceive( EGetPrinterCapEnum, TIpcArgs( i, &valueBuf ) );
       
   333 				LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapEnum err: %d", err);
       
   334 				LOG1("RDirectPrintClient::GetPrinterCapability EGetPrinterCapEnum value: %d", value);
       
   335 				
       
   336 				if( !err )
       
   337 					{
       
   338 					iCapability->iEnumCodes[i] = value;
       
   339 					}
       
   340 				}
       
   341 			}
       
   342 		}
       
   343 
       
   344 	if( !err )
       
   345 		{
       
   346 		aCapability	= *iCapability;
       
   347 		}
       
   348 
       
   349 	LOG1("RDirectPrintClient::GetPrinterCapability end with: %d", err);
       
   350 	return err;
       
   351 	}
       
   352 
       
   353 
       
   354 EXPORT_C TInt RDirectPrintClient::GetPrinterCapabilityIDs( TInt aPrinterID, RArray<TInt>& aCapabilityIDs ) const
       
   355 	{
       
   356 	TInt count;
       
   357 	TPckg<TInt> countBuf( count );
       
   358 	
       
   359 	LOG1("RDirectPrintClient::GetPrinterCapabilityIDs EGetPrinterCapabilityIDsCount aPrinterID: %d", aPrinterID);
       
   360 	TInt err = SendReceive( EGetPrinterCapabilityIDsCount, TIpcArgs( aPrinterID, &countBuf ) );
       
   361 	LOG1("RDirectPrintClient::GetPrinterCapabilityIDs EGetPrinterCapabilityIDsCount err: %d", err);
       
   362 	if( !err )
       
   363 		{
       
   364 		LOG1("RDirectPrintClient::GetPrinterCapabilityIDs EGetPrinterCapabilityIDsCount count: %d", count);
       
   365 		for( TInt i = 0; i < count && !err; i++ )
       
   366 			{
       
   367 			TInt capability;
       
   368 			TPckg<TInt> capBuf( capability );
       
   369 			LOG1("RDirectPrintClient::GetPrinterCapabilityIDs EGetPrinterCapabilityID i: %d", i);
       
   370 			err = SendReceive( EGetPrinterCapabilityID, TIpcArgs( i, &capBuf ) );
       
   371 			LOG1("RDirectPrintClient::GetPrinterCapabilityIDs EGetPrinterCapabilityID err: %d", err);
       
   372 			if( !err )
       
   373 				{
       
   374 				LOG1("RDirectPrintClient::GetPrinterCapabilityIDs capability id: %d", capability);
       
   375 				err = aCapabilityIDs.Append( capability );
       
   376 				LOG1("RDirectPrintClient::GetPrinterCapabilityIDs append err: %d", err);
       
   377 				}
       
   378 			}
       
   379 		}
       
   380 	
       
   381 	LOG1("RDirectPrintClient::GetPrinterCapabilityIDs end with: %d", err);
       
   382 	return err;
       
   383 	}
       
   384 /*
       
   385 EXPORT_C TInt RDirectPrintClient::RegisterIdleObserver( TIdleGuardData& aData, TRequestStatus& aStatus )
       
   386 	{ 
       
   387 	LOG("RDirectPrintClient::RegisterIdleObserver EReserveEngine");
       
   388 	TInt err = SendReceive( EReserveEngine );
       
   389 	LOG1("RDirectPrintClient::RegisterIdleObserver EReserveEngine err: %d", err);
       
   390 	if( !err )
       
   391 		{
       
   392 		LOG("RDirectPrintClient::RegisterIdleObserver ERegisterIdleObserver");
       
   393 		iIdleDataPtr.Set(reinterpret_cast<TUint8*>(&aData), sizeof(aData), sizeof(aData));
       
   394 		SendReceive( ERegisterIdleObserver, TIpcArgs( &iIdleDataPtr ), aStatus );
       
   395 		}
       
   396 	LOG1("RDirectPrintClient::RegisterIdleObserver end with: %d", err);
       
   397 	return err;
       
   398 	}
       
   399 
       
   400 EXPORT_C TInt RDirectPrintClient::CancelRegisterIdleObserver() const 
       
   401 	{
       
   402 	LOG("RDirectPrintClient::CancelRegisterIdleObserver ECancelRegisterIdleObserver");
       
   403 	TInt err = SendReceive( EReleaseEngine );
       
   404 	LOG1("RDirectPrintClient::RegisterIdleObserver EReleaseEngine err: %d", err);
       
   405 
       
   406 	err = SendReceive( ECancelRegisterIdleObserver );
       
   407 	LOG1("RDirectPrintClient::RegisterIdleObserver ECancelRegisterIdleObserver err: %d", err);
       
   408 	
       
   409 	LOG1("RDirectPrintClient::CancelRegisterIdleObserver end with: %d", err);
       
   410 	return err;
       
   411 	}
       
   412 
       
   413 EXPORT_C TInt RDirectPrintClient::StartDiscovery( TDiscoveryGuardData& aData, TUint aProtocols, TRequestStatus& aStatus )
       
   414 	{ 
       
   415 	LOG("RDirectPrintClient::StartDiscovery EReserveEngine");
       
   416 	TInt err = SendReceive( EReserveEngine );
       
   417 	LOG1("RDirectPrintClient::StartDiscovery EReserveEngine err: %d", err);
       
   418 	if( !err )
       
   419 		{ 
       
   420 		LOG1("RDirectPrintClient::StartDiscovery EStartDiscovery aProtocols: %d", aProtocols);
       
   421 		err = SendReceive( EStartDiscovery, TIpcArgs( aProtocols ) );
       
   422 		LOG1("RDirectPrintClient::StartDiscovery EStartDiscovery err: %d", err);
       
   423 		}
       
   424 	if( !err )
       
   425 		{
       
   426 		LOG("RDirectPrintClient::StartDiscovery EContinueDiscovery");
       
   427 		iDicsoveryDataPtr.Set(reinterpret_cast<TUint8*>(&aData), sizeof(aData), sizeof(aData));
       
   428 		SendReceive( EContinueDiscovery, TIpcArgs( &iDicsoveryDataPtr ), aStatus );
       
   429 		}
       
   430 	LOG1("RDirectPrintClient::StartDiscovery end with: %d", err);
       
   431 	return err;
       
   432 	}
       
   433 
       
   434 EXPORT_C TInt RDirectPrintClient::ContinueDiscovery( TDiscoveryGuardData& aData, TRequestStatus& aStatus )
       
   435 	{
       
   436 	LOG("RDirectPrintClient::ContinueDiscovery EReserveEngine");
       
   437 	TInt err = SendReceive( EReserveEngine );
       
   438 	LOG1("RDirectPrintClient::ContinueDiscovery EReserveEngine err: %d", err);
       
   439     if( !err )
       
   440     	{
       
   441     	LOG("RDirectPrintClient::ContinueDiscovery EContinueDiscovery");
       
   442 	    iDicsoveryDataPtr.Set(reinterpret_cast<TUint8*>(&aData), sizeof(aData), sizeof(aData));
       
   443 	    SendReceive( EContinueDiscovery, TIpcArgs( &iDicsoveryDataPtr ), aStatus );
       
   444     	}
       
   445     LOG1("RDirectPrintClient::ContinueDiscovery end with: %d", err);
       
   446     return err;
       
   447 	}
       
   448 */
       
   449 EXPORT_C TInt RDirectPrintClient::CreateJob( TInt aPrinterID, TDirectPrintJobGuardData& aData, RPointerArray<TDesC>& aImages, TRequestStatus& aStatus )
       
   450 	{
       
   451 	LOG("RDirectPrintClient::CreateJob EReserveEngine");
       
   452 	TInt err = SendReceive( EReserveEngine );
       
   453 	LOG1("RDirectPrintClient::CreateJob EReserveEngine err: %d", err);
       
   454 	if( !err )
       
   455 		{
       
   456 		TInt count = aImages.Count();
       
   457 		LOG1("RDirectPrintClient::CreateJob aImages.Count(): %d", aImages.Count());
       
   458 		for( TInt i = 0; i < count && !err; i++ )
       
   459 			{
       
   460 			LOG("RDirectPrintClient::CreateJob EPrepareJob");
       
   461 			err = SendReceive( EPrepareJob, TIpcArgs( aImages[i] ) );
       
   462 			LOG1("RDirectPrintClient::CreateJob EPrepareJob err: %d", err);	
       
   463 			}
       
   464 		}
       
   465     if( !err )
       
   466     	{
       
   467     	LOG("RDirectPrintClient::CreateJob ECreateJob");
       
   468     	err = SendReceive( ECreateJob, TIpcArgs( aPrinterID ) );
       
   469     	LOG1("RDirectPrintClient::CreateJob ECreateJob err: %d", err);
       
   470     	}
       
   471     if( !err )
       
   472     	{ 
       
   473     	LOG("RDirectPrintClient::CreateJob EContinueCreateJob");
       
   474     	iJobDataPtr.Set(reinterpret_cast<TUint8*>(&aData), sizeof(aData), sizeof(aData));
       
   475 	    SendReceive( EContinueCreateJob, TIpcArgs( &iJobDataPtr ), aStatus );
       
   476     	}
       
   477     LOG1("RDirectPrintClient::CreateJob end with: %d", err);
       
   478     return err;
       
   479 	}		
       
   480         
       
   481 EXPORT_C TInt RDirectPrintClient::ContinueCreateJob( TDirectPrintJobGuardData& aData, TRequestStatus& aStatus )
       
   482 	{
       
   483 	LOG("RDirectPrintClient::ContinueCreateJob EReserveEngine");
       
   484 	TInt err = SendReceive( EReserveEngine );
       
   485 	LOG1("RDirectPrintClient::ContinueCreateJob EReserveEngine err: %d", err);
       
   486     if( !err )
       
   487     	{  
       
   488     	LOG("RDirectPrintClient::ContinueCreateJob EContinueCreateJob");  	    	
       
   489     	iJobDataPtr.Set(reinterpret_cast<TUint8*>(&aData), sizeof(aData), sizeof(aData));
       
   490 	    SendReceive( EContinueCreateJob, TIpcArgs( &iJobDataPtr ), aStatus );
       
   491     	}
       
   492     LOG1("RDirectPrintClient::ContinueCreateJob end with: %d", err);
       
   493     return err;
       
   494 	}
       
   495 	
       
   496 EXPORT_C TInt RDirectPrintClient::CancelStartDiscovery() const
       
   497 	{
       
   498 	LOG("RDirectPrintClient::CancelStartDiscovery ECancelStartDiscovery");
       
   499 	TInt err = SendReceive( ECancelStartDiscovery );
       
   500 	LOG1("RDirectPrintClient::CancelStartDiscovery end with: %d", err);
       
   501 	return err;	
       
   502 	}	
       
   503 		
       
   504 EXPORT_C TInt RDirectPrintClient::CancelCreateJob() const
       
   505 	{
       
   506 	LOG("RDirectPrintClient::CancelCreateJob ECancelCreateJob");
       
   507 	TInt err = SendReceive( ECancelCreateJob );
       
   508 	LOG1("RDirectPrintClient::CancelCreateJob end with: %d", err);
       
   509 	return err;	
       
   510 	}
       
   511 	
       
   512 EXPORT_C TInt RDirectPrintClient::IsPictBridgeMode() const
       
   513 	{
       
   514 	LOG("RDirectPrintClient::IsPictBridgeMode EIsPictBridgeMode");
       
   515 #ifdef __WINS__
       
   516 	TInt err( KErrNotFound );
       
   517 #else
       
   518 	TInt err = SendReceive( EIsPictBridgeMode );
       
   519 #endif	
       
   520 	LOG1("RDirectPrintClient::IsPictBridgeMode end with: %d", err);
       
   521 	return err;	
       
   522 	}
       
   523 	
       
   524 EXPORT_C TInt RDirectPrintClient::SetNumberOfCopies( const RArray<TInt>& aArray ) const
       
   525 	{
       
   526 	LOG("RDirectPrintClient::SetNumberOfCopies EReserveEngine");
       
   527 	TInt err = SendReceive( EReserveEngine );
       
   528 	LOG1("RDirectPrintClient::SetNumberOfCopies EReserveEngine err: %d", err);
       
   529     if( !err )
       
   530     	{
       
   531     	TInt count = aArray.Count();
       
   532     	LOG1("RDirectPrintClient::SetNumberOfCopies count: %d", count);
       
   533     	LOG("RDirectPrintClient::SetNumberOfCopies ESetNumberOfCopiesCount");
       
   534 		err = SendReceive( ESetNumberOfCopiesCount, TIpcArgs( count ) );
       
   535 		LOG1("RDirectPrintClient::SetNumberOfCopies ESetNumberOfCopiesCount err: %d", err);
       
   536     	for( TInt i = 0; i < count && !err; i++ )
       
   537 			{
       
   538 			LOG1("RDirectPrintClient::SetNumberOfCopies i: %d", i);
       
   539 			LOG("RDirectPrintClient::SetNumberOfCopies ESetNumberOfCopies");
       
   540 			err = SendReceive( ESetNumberOfCopies, TIpcArgs( aArray[i] ) );
       
   541 			LOG1("RDirectPrintClient::SetNumberOfCopies ESetNumberOfCopies err: %d", err);
       
   542 			}
       
   543     	}
       
   544 	LOG1("RDirectPrintClient::SetNumberOfCopies end with: %d", err);
       
   545 	return err;
       
   546 	}
       
   547 	
       
   548 EXPORT_C TInt RDirectPrintClient::GetProtocolNames(RSelectItemArray& aNames) const
       
   549 	{
       
   550 	//TInt err = SendReceive( EReserveEngine );
       
   551 	TInt count;
       
   552 	TPckg<TInt> countBuf( count );
       
   553 
       
   554 	TInt err = SendReceive( EGetProtocolNamesCount, TIpcArgs( &countBuf ) );
       
   555 
       
   556 	if( !err )
       
   557 		{
       
   558 		aNames.Reset();
       
   559 
       
   560 		for( TInt i = 0; i < count && !err; i++ )
       
   561 			{
       
   562 			TDirectPrintSelectItem item;
       
   563 			//iNameDataPtr.Set(reinterpret_cast<TUint8*>(&item), sizeof(item), sizeof(item));
       
   564 			TPtr8 ptr(reinterpret_cast<TUint8*>(&item), sizeof(item), sizeof(item));
       
   565 			//err = SendReceive( EGetProtocolName, TIpcArgs( i, &iNameDataPtr ) );
       
   566 			err = SendReceive( EGetProtocolName, TIpcArgs( i, &ptr ) );
       
   567 			if( !err )
       
   568 				{
       
   569 				aNames.Append(item);
       
   570 				}
       
   571 			}
       
   572 		}
       
   573 
       
   574 	return err;
       
   575 	}
       
   576 
       
   577 //  End of File