syncmlfw/common/sosserver_clientapi/src/NSmlDMClientAPI.cpp
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Implementation of DM specific client api.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32mem.h>
       
    20 #include <SyncMLClientDM.h>
       
    21 #include <nsmldebug.h>
       
    22 
       
    23 #include "NSmlClientAPIUtils.h"
       
    24 #include "nsmlsosserverdefs.h"
       
    25 
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 //
       
    30 // RSyncMLDevManJob
       
    31 //
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // RSyncMLDevManJob::RSyncMLDevManJob()
       
    35 // Constructor.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 EXPORT_C RSyncMLDevManJob::RSyncMLDevManJob()
       
    39 	: RSyncMLJobBase()
       
    40 	{
       
    41 	}
       
    42 	
       
    43 // -----------------------------------------------------------------------------
       
    44 // RSyncMLDevManJob::CreateL()
       
    45 // Creates DM job.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C void RSyncMLDevManJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId )
       
    49 	{
       
    50 	_DBG_FILE("RSyncMLDevManJob::CreateL() ECmdDevManJobCreate: begin");
       
    51 	
       
    52 	// check that profile is not yet open and dm sync is supported
       
    53 	CClientSessionData::PanicIfAlreadyCreated( iData );
       
    54 	NSmlClientAPIFeatureHandler::LeaveIfDevManNotSupportedL();
       
    55 	
       
    56 	CDevManJobSessionData* data = new (ELeave) CDevManJobSessionData();
       
    57 	CleanupStack::PushL( data );
       
    58 
       
    59 	// add profile id to parameters and write the buffer
       
    60 	data->AddParamL( aProfileId );
       
    61 	data->WriteIntegersToBufferL();
       
    62 	
       
    63 	TPtr8 dataPtr = data->DataBufferPtr();
       
    64 	TPckgBuf<TInt> jobId;
       
    65 	TIpcArgs args( &jobId, &dataPtr );
       
    66     
       
    67 	// open the sub-session
       
    68 	User::LeaveIfError( CreateSubSession( aSession, ECmdDevManJobCreate, args ) );
       
    69 	
       
    70 	data->SetProfile( aProfileId );
       
    71 	data->SetIdentifier( jobId() );
       
    72 	
       
    73 	iData = data;
       
    74 	CleanupStack::Pop(); // data
       
    75 	
       
    76 	_DBG_FILE("RSyncMLDevManJob::CreateL(): end");
       
    77 	}
       
    78 	
       
    79 // -----------------------------------------------------------------------------
       
    80 // RSyncMLDevManJob::CreateL()
       
    81 // Creates DM job, transport override.
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 EXPORT_C void RSyncMLDevManJob::CreateL( RSyncMLSession& aSession, TSmlProfileId aProfileId, TSmlConnectionId aTransportId )
       
    85 	{
       
    86 	_DBG_FILE("RSyncMLDevManJob::CreateL() ECmdDevManJobCreateForTransport: begin");
       
    87 	
       
    88 	// check that profile is not yet open and dm sync is supported
       
    89 	CClientSessionData::PanicIfAlreadyCreated( iData );
       
    90 	NSmlClientAPIFeatureHandler::LeaveIfDevManNotSupportedL();
       
    91 		
       
    92 	CDevManJobSessionData* data = new (ELeave) CDevManJobSessionData();
       
    93 	CleanupStack::PushL( data );
       
    94 
       
    95 	// add profile id to parameters and write the buffer
       
    96 	data->AddParamL( aProfileId );
       
    97 	data->AddParamL( aTransportId );
       
    98 	data->WriteIntegersToBufferL();
       
    99 	
       
   100 	TPtr8 dataPtr = data->DataBufferPtr();
       
   101 	TPckgBuf<TInt> jobId;
       
   102 	TIpcArgs args( &jobId, &dataPtr );
       
   103     
       
   104 	// open the sub-session
       
   105 	User::LeaveIfError( CreateSubSession( aSession, ECmdDevManJobCreateForTransport, args ) );
       
   106 	
       
   107 	data->SetProfile( aProfileId );
       
   108 	data->SetIdentifier( jobId() );
       
   109 	
       
   110 	iData = data;
       
   111 	CleanupStack::Pop(); // data
       
   112 	
       
   113 	_DBG_FILE("RSyncMLDevManJob::CreateL(): end");
       
   114 	}
       
   115 	
       
   116 // -----------------------------------------------------------------------------
       
   117 // RSyncMLDevManJob::OpenL().
       
   118 // Opens given job. If not found, leaves with KErrNotFound.
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 EXPORT_C void RSyncMLDevManJob::OpenL( RSyncMLSession& aSession, TSmlJobId aJobId )
       
   122 	{
       
   123 	_DBG_FILE("RSyncMLDevManJob::OpenL(): begin");
       
   124 	
       
   125 	CClientSessionData::PanicIfAlreadyCreated( iData );
       
   126 		
       
   127 	CDevManJobSessionData* data = new (ELeave) CDevManJobSessionData();
       
   128 	CleanupStack::PushL( data );
       
   129 
       
   130 	// open the sub-session and get size of data to be received
       
   131 	TPckgBuf<TInt> dataSize;
       
   132 	TIpcArgs args( &dataSize, aJobId );
       
   133 	User::LeaveIfError( CreateSubSession( aSession, ECmdJobOpen, args ) );
       
   134 	
       
   135 	data->SetIdentifier( aJobId );
       
   136 	
       
   137 	iData = data;
       
   138 	CleanupStack::Pop(); // data
       
   139 	
       
   140 	CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup
       
   141 	
       
   142 	// get the data
       
   143 	GetJobL( dataSize(), EFalse );
       
   144 	
       
   145 	CleanupStack::Pop(); // this
       
   146 	
       
   147 	_DBG_FILE("RSyncMLDevManJob::OpenL(): end");
       
   148 	}
       
   149 	
       
   150 // -----------------------------------------------------------------------------
       
   151 // RSyncMLDevManJob::StopL()
       
   152 // If this job has started to execute in server, it is stopped and an 
       
   153 // event is emitted. If the job is still in job queue, it is merely 
       
   154 // removed from the queue. If not found, leaves with KErrNotFound.
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 EXPORT_C void RSyncMLDevManJob::StopL()
       
   158 	{
       
   159 	_DBG_FILE("RSyncMLDevManJob::StopL(): begin");
       
   160 	
       
   161 	TInt jobId = Identifier();
       
   162 	TIpcArgs args( jobId );
       
   163 	User::LeaveIfError( SendReceive( ECmdJobStop, args ) );
       
   164 	
       
   165 	_DBG_FILE("RSyncMLDevManJob::StopL(): end");
       
   166 	}
       
   167 	
       
   168 
       
   169 //
       
   170 // RSyncMLDevManProfile
       
   171 //
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // RSyncMLDevManProfile::RSyncMLDevManProfile()
       
   175 // Constructor.
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C RSyncMLDevManProfile::RSyncMLDevManProfile()
       
   179 	: RSyncMLProfileBase()
       
   180 	{
       
   181 	}
       
   182 	
       
   183 // -----------------------------------------------------------------------------
       
   184 // RSyncMLDevManProfile::OpenL()
       
   185 // Opens given profile in read-only mode.
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 EXPORT_C void RSyncMLDevManProfile::OpenL( RSyncMLSession& aSession, TSmlProfileId aProfileId )
       
   189 	{
       
   190 	_DBG_FILE("RSyncMLDevManProfile::OpenL(): begin");
       
   191 	
       
   192 	OpenL( aSession, aProfileId, ESmlOpenRead );
       
   193 	
       
   194 	_DBG_FILE("RSyncMLDevManProfile::OpenL(): end");
       
   195 	}
       
   196 	
       
   197 // -----------------------------------------------------------------------------
       
   198 // RSyncMLDevManProfile::OpenL()
       
   199 // Opens given profile.
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 EXPORT_C void RSyncMLDevManProfile::OpenL( RSyncMLSession& aSession, TSmlProfileId aProfileId, TSmlOpenMode aOpenMode )
       
   203 	{
       
   204 	_DBG_FILE("RSyncMLDevManProfile::OpenL(): begin");
       
   205 	
       
   206 	CClientSessionData::PanicIfAlreadyCreated( iData );
       
   207 		
       
   208 	CDevManProfileSessionData* data = CDevManProfileSessionData::NewLC();
       
   209 	
       
   210 	TPckgBuf<TInt> dataSize;
       
   211 	TIpcArgs args( &dataSize, aProfileId, aOpenMode );
       
   212     
       
   213 	// open the sub-session
       
   214 	User::LeaveIfError( CreateSubSession( aSession, ECmdProfileOpenDM, args ) );
       
   215 	
       
   216 	data->SetIdentifier( aProfileId );
       
   217 	data->SetOpenMode( (TSmlOpenMode)aOpenMode );
       
   218 	
       
   219 	iData = data;
       
   220 	CleanupStack::Pop(); // data
       
   221 	
       
   222 	CleanupClosePushL( *this ); // if leave occures, Close is called by cleanup
       
   223 	
       
   224 	// dataSize contains now the size of the data buffer that is received next -> get data
       
   225 	GetProfileL( dataSize() );
       
   226 	
       
   227 	CleanupStack::Pop(); // this
       
   228 	
       
   229 	_DBG_FILE("RSyncMLDevManProfile::OpenL(): end");
       
   230 	}
       
   231 	
       
   232 // -----------------------------------------------------------------------------
       
   233 // RSyncMLDevManProfile::CreateL()
       
   234 // Creates new DM profile.
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 EXPORT_C void RSyncMLDevManProfile::CreateL( RSyncMLSession& aSession )
       
   238 	{
       
   239 	_DBG_FILE("RSyncMLDevManProfile::CreateL(): begin");
       
   240 	
       
   241 	// check that profile is not yet open and dm sync is supported
       
   242 	CClientSessionData::PanicIfAlreadyCreated( iData );
       
   243 	NSmlClientAPIFeatureHandler::LeaveIfDevManNotSupportedL();
       
   244 		
       
   245 	CDevManProfileSessionData* data = CDevManProfileSessionData::NewLC( ETrue );
       
   246 	
       
   247 	// create sub-session and new profile
       
   248 	User::LeaveIfError( CreateSubSession( aSession, ECmdProfileCreateDM ) );
       
   249 
       
   250 	iData = data;
       
   251 	CleanupStack::Pop(); // data
       
   252 	
       
   253 	_DBG_FILE("RSyncMLDevManProfile::CreateL(): end");
       
   254 	}
       
   255 	
       
   256 
       
   257 
       
   258 //
       
   259 // RSyncMLDevMan ( Not supported )
       
   260 //
       
   261 
       
   262 // -----------------------------------------------------------------------------
       
   263 // RSyncMLDevMan::RSyncMLDevMan()
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 EXPORT_C RSyncMLDevMan::RSyncMLDevMan()
       
   267 	{
       
   268 	}
       
   269 	
       
   270 // -----------------------------------------------------------------------------
       
   271 // RSyncMLDevMan::OpenL()
       
   272 // -----------------------------------------------------------------------------
       
   273 //
       
   274 EXPORT_C void RSyncMLDevMan::OpenL( RSyncMLSession& )
       
   275 	{
       
   276 	User::Leave( KErrNotSupported );
       
   277 	}
       
   278 	
       
   279 // -----------------------------------------------------------------------------
       
   280 // RSyncMLDevMan::ClearRootAclL()
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 EXPORT_C void RSyncMLDevMan::ClearRootAclL()
       
   284 	{
       
   285 	User::Leave( KErrNotSupported );
       
   286 	}
       
   287 	
       
   288 // -----------------------------------------------------------------------------
       
   289 // RSyncMLDevMan::SetUserInteractionNotifierTimeoutL()
       
   290 // -----------------------------------------------------------------------------
       
   291 //
       
   292 EXPORT_C void RSyncMLDevMan::SetUserInteractionNotifierTimeoutL( TUint /*aSeconds*/ )
       
   293 	{
       
   294 	User::Leave( KErrNotSupported );
       
   295 	}
       
   296 	
       
   297 // -----------------------------------------------------------------------------
       
   298 // RSyncMLDevMan::UserInteractionNotifierTimeout()
       
   299 // -----------------------------------------------------------------------------
       
   300 //
       
   301 EXPORT_C TUint RSyncMLDevMan::UserInteractionNotifierTimeout() const
       
   302 	{
       
   303 	return 0;
       
   304 	}
       
   305 	
       
   306 // -----------------------------------------------------------------------------
       
   307 // RSyncMLDevMan::Close()
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 EXPORT_C void RSyncMLDevMan::Close()
       
   311 	{
       
   312 	}
       
   313 	
       
   314 
       
   315 
       
   316 
       
   317 
       
   318