brandingserver/BSClient/cbsupdater.cpp
author hgs
Sun, 11 Apr 2010 15:33:49 +0530
changeset 31 9dbc70490d9a
permissions -rw-r--r--
201014
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  CBSUpdater.cpp
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
//  INCLUDE FILES
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
#include "e32base.h"
hgs
parents:
diff changeset
    23
hgs
parents:
diff changeset
    24
#include "cbsupdater.h"
hgs
parents:
diff changeset
    25
#include "DebugTrace.h"
hgs
parents:
diff changeset
    26
#include "mbsaccess.h"
hgs
parents:
diff changeset
    27
#include "bselementfactory.h"
hgs
parents:
diff changeset
    28
#include "mbselement.h"
hgs
parents:
diff changeset
    29
#include "bsserverdefs.h"
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
// Two-phased constructor.
hgs
parents:
diff changeset
    32
CBSUpdater* CBSUpdater::NewL( const TDesC8& aApplicationId )
hgs
parents:
diff changeset
    33
    {
hgs
parents:
diff changeset
    34
    CBSUpdater* self = new ( ELeave ) CBSUpdater() ;
hgs
parents:
diff changeset
    35
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
    36
    self->ConstructL( aApplicationId );
hgs
parents:
diff changeset
    37
    CleanupStack::Pop( self );  //self
hgs
parents:
diff changeset
    38
    return self;
hgs
parents:
diff changeset
    39
    }
hgs
parents:
diff changeset
    40
hgs
parents:
diff changeset
    41
// Symbian OS default constructor can leave.
hgs
parents:
diff changeset
    42
void CBSUpdater::ConstructL( const TDesC8& aApplicationId  )
hgs
parents:
diff changeset
    43
    {
hgs
parents:
diff changeset
    44
    iApplicationId = aApplicationId.AllocL();
hgs
parents:
diff changeset
    45
    User::LeaveIfError( iClient.Connect() );
hgs
parents:
diff changeset
    46
    }
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
// Destructor
hgs
parents:
diff changeset
    49
CBSUpdater::~CBSUpdater()
hgs
parents:
diff changeset
    50
    {
hgs
parents:
diff changeset
    51
    delete iApplicationId;
hgs
parents:
diff changeset
    52
    delete iBrandId;
hgs
parents:
diff changeset
    53
    iClient.Close();
hgs
parents:
diff changeset
    54
    }
hgs
parents:
diff changeset
    55
hgs
parents:
diff changeset
    56
// C++ default constructor can NOT contain any code, that
hgs
parents:
diff changeset
    57
// might leave.
hgs
parents:
diff changeset
    58
//
hgs
parents:
diff changeset
    59
CBSUpdater::CBSUpdater()
hgs
parents:
diff changeset
    60
	{
hgs
parents:
diff changeset
    61
	}
hgs
parents:
diff changeset
    62
hgs
parents:
diff changeset
    63
hgs
parents:
diff changeset
    64
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    65
// CBSUpdater::Close()
hgs
parents:
diff changeset
    66
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    67
//
hgs
parents:
diff changeset
    68
void CBSUpdater::Close()
hgs
parents:
diff changeset
    69
	{
hgs
parents:
diff changeset
    70
	delete this;
hgs
parents:
diff changeset
    71
	}
hgs
parents:
diff changeset
    72
hgs
parents:
diff changeset
    73
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    74
// CBSUpdater::StartTransactionL()
hgs
parents:
diff changeset
    75
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
    76
//
hgs
parents:
diff changeset
    77
void CBSUpdater::StartTransactionL( const TDesC8& aBrandId,
hgs
parents:
diff changeset
    78
									TLanguage aLanguageId,
hgs
parents:
diff changeset
    79
									TUpdateTransactionType aType, /*EUpdateInstall*/
hgs
parents:
diff changeset
    80
									TInt aReserved)
hgs
parents:
diff changeset
    81
	{
hgs
parents:
diff changeset
    82
	if( iActive )
hgs
parents:
diff changeset
    83
		{
hgs
parents:
diff changeset
    84
		User::Leave( KErrAlreadyExists );
hgs
parents:
diff changeset
    85
		}
hgs
parents:
diff changeset
    86
	
hgs
parents:
diff changeset
    87
	iActive = ETrue;
hgs
parents:
diff changeset
    88
	HBufC8* tmp = aBrandId.AllocL();
hgs
parents:
diff changeset
    89
	delete iBrandId;
hgs
parents:
diff changeset
    90
	iBrandId = tmp;
hgs
parents:
diff changeset
    91
	iLanguageId = aLanguageId;
hgs
parents:
diff changeset
    92
	iReserved = aReserved;
hgs
parents:
diff changeset
    93
	iTxType = aType;
hgs
parents:
diff changeset
    94
	
hgs
parents:
diff changeset
    95
	TTransactionType operation = EBSTxAccess;
hgs
parents:
diff changeset
    96
	switch( aType )
hgs
parents:
diff changeset
    97
		{
hgs
parents:
diff changeset
    98
		case EUpdateInstall:
hgs
parents:
diff changeset
    99
			{
hgs
parents:
diff changeset
   100
			operation = EBSTxInstall;
hgs
parents:
diff changeset
   101
			break;
hgs
parents:
diff changeset
   102
			}
hgs
parents:
diff changeset
   103
		case EUpdateAppend:
hgs
parents:
diff changeset
   104
			{
hgs
parents:
diff changeset
   105
			operation = EBSTxAppend;
hgs
parents:
diff changeset
   106
			break;
hgs
parents:
diff changeset
   107
			}
hgs
parents:
diff changeset
   108
		case EUpdateReplace:
hgs
parents:
diff changeset
   109
			{
hgs
parents:
diff changeset
   110
			operation = EBSTxReplace;
hgs
parents:
diff changeset
   111
			break;
hgs
parents:
diff changeset
   112
			}
hgs
parents:
diff changeset
   113
		case EUpdateUninstall:
hgs
parents:
diff changeset
   114
			{
hgs
parents:
diff changeset
   115
			operation = EBSTxUninstall;
hgs
parents:
diff changeset
   116
			break;
hgs
parents:
diff changeset
   117
			}
hgs
parents:
diff changeset
   118
		default:
hgs
parents:
diff changeset
   119
			break;
hgs
parents:
diff changeset
   120
		}
hgs
parents:
diff changeset
   121
	
hgs
parents:
diff changeset
   122
	TRAPD( err, iClient.StartTransactionL( *iApplicationId, aBrandId, KNullDesC8,
hgs
parents:
diff changeset
   123
									aLanguageId, operation, aReserved ) );
hgs
parents:
diff changeset
   124
	if( err )
hgs
parents:
diff changeset
   125
		{
hgs
parents:
diff changeset
   126
		iActive = EFalse;
hgs
parents:
diff changeset
   127
		User::Leave( err );
hgs
parents:
diff changeset
   128
		}
hgs
parents:
diff changeset
   129
hgs
parents:
diff changeset
   130
	}
hgs
parents:
diff changeset
   131
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   132
// CBSUpdater::StopTransactionL()
hgs
parents:
diff changeset
   133
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   134
//
hgs
parents:
diff changeset
   135
TInt CBSUpdater::StopTransactionL()
hgs
parents:
diff changeset
   136
	{
hgs
parents:
diff changeset
   137
	if( !iActive )
hgs
parents:
diff changeset
   138
		{
hgs
parents:
diff changeset
   139
		User::Leave( KErrNotFound );
hgs
parents:
diff changeset
   140
		}
hgs
parents:
diff changeset
   141
	
hgs
parents:
diff changeset
   142
	TInt returnValue = iClient.StopTransactionL( *iApplicationId, 
hgs
parents:
diff changeset
   143
												 *iBrandId, 
hgs
parents:
diff changeset
   144
												 iLanguageId, 
hgs
parents:
diff changeset
   145
												 iReserved );
hgs
parents:
diff changeset
   146
	iActive = EFalse;
hgs
parents:
diff changeset
   147
	return returnValue;
hgs
parents:
diff changeset
   148
	}
hgs
parents:
diff changeset
   149
hgs
parents:
diff changeset
   150
hgs
parents:
diff changeset
   151
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   152
// CBSUpdater::CancelTransactionL()
hgs
parents:
diff changeset
   153
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   154
//
hgs
parents:
diff changeset
   155
void CBSUpdater::CancelTransactionL()
hgs
parents:
diff changeset
   156
	{
hgs
parents:
diff changeset
   157
	if( !iActive )
hgs
parents:
diff changeset
   158
		{
hgs
parents:
diff changeset
   159
		User::Leave( KErrNotFound );
hgs
parents:
diff changeset
   160
		}
hgs
parents:
diff changeset
   161
	
hgs
parents:
diff changeset
   162
	iClient.CancelTransactionL( *iApplicationId, *iBrandId, iLanguageId, iReserved );
hgs
parents:
diff changeset
   163
	iActive = EFalse;
hgs
parents:
diff changeset
   164
	}
hgs
parents:
diff changeset
   165
hgs
parents:
diff changeset
   166
hgs
parents:
diff changeset
   167
hgs
parents:
diff changeset
   168
//*** BRAND INSTALLING ***//
hgs
parents:
diff changeset
   169
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   170
// CBSUpdater::InsertTextL()
hgs
parents:
diff changeset
   171
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   172
//
hgs
parents:
diff changeset
   173
void CBSUpdater::InsertTextL( const TDesC8& aId,
hgs
parents:
diff changeset
   174
				  			  const TDesC& aText )
hgs
parents:
diff changeset
   175
	{
hgs
parents:
diff changeset
   176
	if( !iActive )
hgs
parents:
diff changeset
   177
		{
hgs
parents:
diff changeset
   178
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   179
		}
hgs
parents:
diff changeset
   180
	if( iTxType != EUpdateInstall )
hgs
parents:
diff changeset
   181
		{
hgs
parents:
diff changeset
   182
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   183
		}
hgs
parents:
diff changeset
   184
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSText, aText );
hgs
parents:
diff changeset
   185
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   186
	InsertElementL( element );
hgs
parents:
diff changeset
   187
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   188
	}
hgs
parents:
diff changeset
   189
hgs
parents:
diff changeset
   190
hgs
parents:
diff changeset
   191
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   192
// CBSUpdater::InsertBufferL()
hgs
parents:
diff changeset
   193
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   194
//
hgs
parents:
diff changeset
   195
void CBSUpdater::InsertBufferL( const TDesC8& aId,
hgs
parents:
diff changeset
   196
								const TDesC8& aBuffer )
hgs
parents:
diff changeset
   197
	{
hgs
parents:
diff changeset
   198
	if( !iActive )
hgs
parents:
diff changeset
   199
		{
hgs
parents:
diff changeset
   200
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   201
		}
hgs
parents:
diff changeset
   202
	if( iTxType != EUpdateInstall )
hgs
parents:
diff changeset
   203
		{
hgs
parents:
diff changeset
   204
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   205
		}
hgs
parents:
diff changeset
   206
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSBuffer, aBuffer );
hgs
parents:
diff changeset
   207
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   208
	InsertElementL( element );
hgs
parents:
diff changeset
   209
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   210
	}
hgs
parents:
diff changeset
   211
hgs
parents:
diff changeset
   212
hgs
parents:
diff changeset
   213
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   214
// CBSUpdater::InsertIntL()
hgs
parents:
diff changeset
   215
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   216
//
hgs
parents:
diff changeset
   217
void CBSUpdater::InsertIntL( const TDesC8& aId,
hgs
parents:
diff changeset
   218
				 			 TInt aInt )
hgs
parents:
diff changeset
   219
	{
hgs
parents:
diff changeset
   220
	if( !iActive )
hgs
parents:
diff changeset
   221
		{
hgs
parents:
diff changeset
   222
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   223
		}
hgs
parents:
diff changeset
   224
	if( iTxType != EUpdateInstall )
hgs
parents:
diff changeset
   225
		{
hgs
parents:
diff changeset
   226
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   227
		}
hgs
parents:
diff changeset
   228
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSInt, aInt );
hgs
parents:
diff changeset
   229
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   230
	InsertElementL( element );
hgs
parents:
diff changeset
   231
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   232
	}
hgs
parents:
diff changeset
   233
hgs
parents:
diff changeset
   234
hgs
parents:
diff changeset
   235
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   236
// CBSUpdater::InsertFileL()
hgs
parents:
diff changeset
   237
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   238
//
hgs
parents:
diff changeset
   239
void CBSUpdater::InsertFileL( const TDesC8& aId,
hgs
parents:
diff changeset
   240
				  			  const TDesC& aFileName )
hgs
parents:
diff changeset
   241
	{
hgs
parents:
diff changeset
   242
	if( !iActive )
hgs
parents:
diff changeset
   243
		{
hgs
parents:
diff changeset
   244
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   245
		}
hgs
parents:
diff changeset
   246
	if( iTxType != EUpdateInstall )
hgs
parents:
diff changeset
   247
		{
hgs
parents:
diff changeset
   248
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   249
		}
hgs
parents:
diff changeset
   250
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSFile, aFileName );
hgs
parents:
diff changeset
   251
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   252
	InsertElementL( element );
hgs
parents:
diff changeset
   253
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   254
	}
hgs
parents:
diff changeset
   255
hgs
parents:
diff changeset
   256
hgs
parents:
diff changeset
   257
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   258
// CBSUpdater::InsertElementL()
hgs
parents:
diff changeset
   259
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   260
//
hgs
parents:
diff changeset
   261
void CBSUpdater::InsertElementL( MBSElement* aElement )
hgs
parents:
diff changeset
   262
	{
hgs
parents:
diff changeset
   263
	if( !iActive )
hgs
parents:
diff changeset
   264
		{
hgs
parents:
diff changeset
   265
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   266
		}
hgs
parents:
diff changeset
   267
	if( iTxType != EUpdateInstall )
hgs
parents:
diff changeset
   268
		{
hgs
parents:
diff changeset
   269
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   270
		}
hgs
parents:
diff changeset
   271
	iClient.InsertL( aElement );
hgs
parents:
diff changeset
   272
	}
hgs
parents:
diff changeset
   273
hgs
parents:
diff changeset
   274
hgs
parents:
diff changeset
   275
hgs
parents:
diff changeset
   276
hgs
parents:
diff changeset
   277
//*** BRAND UPDATING - replacing ***//
hgs
parents:
diff changeset
   278
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   279
// CBSUpdater::ReplaceTextL()
hgs
parents:
diff changeset
   280
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   281
//
hgs
parents:
diff changeset
   282
void CBSUpdater::ReplaceTextL( const TDesC8& aId,
hgs
parents:
diff changeset
   283
				   			   const TDesC& aText )
hgs
parents:
diff changeset
   284
	{
hgs
parents:
diff changeset
   285
	if( !iActive )
hgs
parents:
diff changeset
   286
		{
hgs
parents:
diff changeset
   287
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   288
		}
hgs
parents:
diff changeset
   289
	if( iTxType != EUpdateReplace )
hgs
parents:
diff changeset
   290
		{
hgs
parents:
diff changeset
   291
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   292
		}
hgs
parents:
diff changeset
   293
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSText, aText );
hgs
parents:
diff changeset
   294
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   295
	ReplaceElementL( element );
hgs
parents:
diff changeset
   296
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   297
	}
hgs
parents:
diff changeset
   298
hgs
parents:
diff changeset
   299
hgs
parents:
diff changeset
   300
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   301
// CBSUpdater::ReplaceBufferL()
hgs
parents:
diff changeset
   302
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   303
//
hgs
parents:
diff changeset
   304
void CBSUpdater::ReplaceBufferL( const TDesC8& aId,
hgs
parents:
diff changeset
   305
					 			 const TDesC8& aBuffer )
hgs
parents:
diff changeset
   306
	{
hgs
parents:
diff changeset
   307
	if( !iActive )
hgs
parents:
diff changeset
   308
		{
hgs
parents:
diff changeset
   309
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   310
		}
hgs
parents:
diff changeset
   311
	if( iTxType != EUpdateReplace )
hgs
parents:
diff changeset
   312
		{
hgs
parents:
diff changeset
   313
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   314
		}
hgs
parents:
diff changeset
   315
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSBuffer, aBuffer );
hgs
parents:
diff changeset
   316
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   317
	ReplaceElementL( element );
hgs
parents:
diff changeset
   318
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   319
	}
hgs
parents:
diff changeset
   320
hgs
parents:
diff changeset
   321
hgs
parents:
diff changeset
   322
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   323
// CBSUpdater::ReplaceIntL()
hgs
parents:
diff changeset
   324
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   325
//
hgs
parents:
diff changeset
   326
void CBSUpdater::ReplaceIntL( const TDesC8& aId,
hgs
parents:
diff changeset
   327
				  			  TInt aInt )
hgs
parents:
diff changeset
   328
	{
hgs
parents:
diff changeset
   329
	if( !iActive )
hgs
parents:
diff changeset
   330
		{
hgs
parents:
diff changeset
   331
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   332
		}
hgs
parents:
diff changeset
   333
	if( iTxType != EUpdateReplace )
hgs
parents:
diff changeset
   334
		{
hgs
parents:
diff changeset
   335
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   336
		}
hgs
parents:
diff changeset
   337
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSInt, aInt );
hgs
parents:
diff changeset
   338
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   339
	ReplaceElementL( element );
hgs
parents:
diff changeset
   340
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   341
	}
hgs
parents:
diff changeset
   342
hgs
parents:
diff changeset
   343
hgs
parents:
diff changeset
   344
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   345
// CBSUpdater::ReplaceFileL()
hgs
parents:
diff changeset
   346
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   347
//
hgs
parents:
diff changeset
   348
void CBSUpdater::ReplaceFileL( const TDesC8& aId,
hgs
parents:
diff changeset
   349
				   			   const TDesC& aFileName )
hgs
parents:
diff changeset
   350
	{
hgs
parents:
diff changeset
   351
	if( !iActive )
hgs
parents:
diff changeset
   352
		{
hgs
parents:
diff changeset
   353
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   354
		}
hgs
parents:
diff changeset
   355
	if( iTxType != EUpdateReplace )
hgs
parents:
diff changeset
   356
		{
hgs
parents:
diff changeset
   357
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   358
		}
hgs
parents:
diff changeset
   359
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSFile, aFileName );
hgs
parents:
diff changeset
   360
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   361
	ReplaceElementL( element );
hgs
parents:
diff changeset
   362
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   363
	}
hgs
parents:
diff changeset
   364
hgs
parents:
diff changeset
   365
hgs
parents:
diff changeset
   366
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   367
// CBSUpdater::ReplaceElementL()
hgs
parents:
diff changeset
   368
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   369
//
hgs
parents:
diff changeset
   370
void CBSUpdater::ReplaceElementL( MBSElement* aElement )
hgs
parents:
diff changeset
   371
	{
hgs
parents:
diff changeset
   372
	if( !iActive )
hgs
parents:
diff changeset
   373
		{
hgs
parents:
diff changeset
   374
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   375
		}
hgs
parents:
diff changeset
   376
	if( iTxType != EUpdateReplace )
hgs
parents:
diff changeset
   377
		{
hgs
parents:
diff changeset
   378
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   379
		}
hgs
parents:
diff changeset
   380
	iClient.ReplaceL( aElement );
hgs
parents:
diff changeset
   381
	}
hgs
parents:
diff changeset
   382
hgs
parents:
diff changeset
   383
hgs
parents:
diff changeset
   384
hgs
parents:
diff changeset
   385
hgs
parents:
diff changeset
   386
//*** BRAND UPDATING - appending ***//
hgs
parents:
diff changeset
   387
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   388
// CBSUpdater::AppendTextL()
hgs
parents:
diff changeset
   389
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   390
//
hgs
parents:
diff changeset
   391
void CBSUpdater::AppendTextL( const TDesC8& aId,
hgs
parents:
diff changeset
   392
				  			  const TDesC& aText )
hgs
parents:
diff changeset
   393
	{
hgs
parents:
diff changeset
   394
	if( !iActive )
hgs
parents:
diff changeset
   395
		{
hgs
parents:
diff changeset
   396
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   397
		}
hgs
parents:
diff changeset
   398
	if( iTxType != EUpdateAppend )
hgs
parents:
diff changeset
   399
		{
hgs
parents:
diff changeset
   400
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   401
		}
hgs
parents:
diff changeset
   402
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSText, aText );
hgs
parents:
diff changeset
   403
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   404
	AppendElementL( element );
hgs
parents:
diff changeset
   405
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   406
	}
hgs
parents:
diff changeset
   407
hgs
parents:
diff changeset
   408
hgs
parents:
diff changeset
   409
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   410
// CBSUpdater::AppendBufferL()
hgs
parents:
diff changeset
   411
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   412
//
hgs
parents:
diff changeset
   413
void CBSUpdater::AppendBufferL( const TDesC8& aId,
hgs
parents:
diff changeset
   414
								const TDesC8& aBuffer )
hgs
parents:
diff changeset
   415
	{
hgs
parents:
diff changeset
   416
	if( !iActive )
hgs
parents:
diff changeset
   417
		{
hgs
parents:
diff changeset
   418
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   419
		}
hgs
parents:
diff changeset
   420
	if( iTxType != EUpdateAppend )
hgs
parents:
diff changeset
   421
		{
hgs
parents:
diff changeset
   422
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   423
		}
hgs
parents:
diff changeset
   424
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSBuffer, aBuffer );
hgs
parents:
diff changeset
   425
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   426
	AppendElementL( element );
hgs
parents:
diff changeset
   427
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   428
	}
hgs
parents:
diff changeset
   429
hgs
parents:
diff changeset
   430
hgs
parents:
diff changeset
   431
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   432
// CBSUpdater::AppendIntL()
hgs
parents:
diff changeset
   433
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   434
//
hgs
parents:
diff changeset
   435
void CBSUpdater::AppendIntL( const TDesC8& aId,
hgs
parents:
diff changeset
   436
				 		     TInt aInt )
hgs
parents:
diff changeset
   437
	{
hgs
parents:
diff changeset
   438
	if( !iActive )
hgs
parents:
diff changeset
   439
		{
hgs
parents:
diff changeset
   440
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   441
		}
hgs
parents:
diff changeset
   442
	if( iTxType != EUpdateAppend )
hgs
parents:
diff changeset
   443
		{
hgs
parents:
diff changeset
   444
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   445
		}
hgs
parents:
diff changeset
   446
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSInt, aInt );
hgs
parents:
diff changeset
   447
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   448
	AppendElementL( element );
hgs
parents:
diff changeset
   449
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   450
	}
hgs
parents:
diff changeset
   451
hgs
parents:
diff changeset
   452
hgs
parents:
diff changeset
   453
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   454
// CBSUpdater::AppendFileL()
hgs
parents:
diff changeset
   455
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   456
//
hgs
parents:
diff changeset
   457
void CBSUpdater::AppendFileL( const TDesC8& aId,
hgs
parents:
diff changeset
   458
				  			  const TDesC& aFileName )
hgs
parents:
diff changeset
   459
	{
hgs
parents:
diff changeset
   460
	if( !iActive )
hgs
parents:
diff changeset
   461
		{
hgs
parents:
diff changeset
   462
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   463
		}
hgs
parents:
diff changeset
   464
	if( iTxType != EUpdateAppend )
hgs
parents:
diff changeset
   465
		{
hgs
parents:
diff changeset
   466
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   467
		}
hgs
parents:
diff changeset
   468
	MBSElement* element = BSElementFactory::CreateBSElementL( aId, EBSFile, aFileName );
hgs
parents:
diff changeset
   469
	CleanupClosePushL( *element );
hgs
parents:
diff changeset
   470
	AppendElementL( element );
hgs
parents:
diff changeset
   471
	CleanupStack::PopAndDestroy(); // element
hgs
parents:
diff changeset
   472
	}
hgs
parents:
diff changeset
   473
hgs
parents:
diff changeset
   474
hgs
parents:
diff changeset
   475
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   476
// CBSUpdater::AppendElementL()
hgs
parents:
diff changeset
   477
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   478
//
hgs
parents:
diff changeset
   479
void CBSUpdater::AppendElementL( MBSElement* aElement )
hgs
parents:
diff changeset
   480
	{
hgs
parents:
diff changeset
   481
	if( !iActive )
hgs
parents:
diff changeset
   482
		{
hgs
parents:
diff changeset
   483
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   484
		}
hgs
parents:
diff changeset
   485
	if( iTxType != EUpdateAppend )
hgs
parents:
diff changeset
   486
		{
hgs
parents:
diff changeset
   487
		User::Leave( KErrArgument );
hgs
parents:
diff changeset
   488
		}
hgs
parents:
diff changeset
   489
	iClient.AppendL( aElement );
hgs
parents:
diff changeset
   490
	}
hgs
parents:
diff changeset
   491
hgs
parents:
diff changeset
   492
hgs
parents:
diff changeset
   493
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   494
// CBSUpdater::AppendElementL()
hgs
parents:
diff changeset
   495
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   496
//
hgs
parents:
diff changeset
   497
void CBSUpdater::RemoveBrandL( const TDesC8& aApplicationId,
hgs
parents:
diff changeset
   498
								   const TDesC8& aBrandId )
hgs
parents:
diff changeset
   499
	{
hgs
parents:
diff changeset
   500
	if( !iActive )
hgs
parents:
diff changeset
   501
		{
hgs
parents:
diff changeset
   502
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   503
		}
hgs
parents:
diff changeset
   504
	iClient.RemoveBrandL( aApplicationId, aBrandId );
hgs
parents:
diff changeset
   505
	}
hgs
parents:
diff changeset
   506
hgs
parents:
diff changeset
   507
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   508
// CBSUpdater::AppendElementL()
hgs
parents:
diff changeset
   509
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   510
//
hgs
parents:
diff changeset
   511
void CBSUpdater:: RemoveBrandsL( const TDesC8& aApplicationId )
hgs
parents:
diff changeset
   512
	{
hgs
parents:
diff changeset
   513
	if( !iActive )
hgs
parents:
diff changeset
   514
		{
hgs
parents:
diff changeset
   515
		User::Leave( KErrNotReady );
hgs
parents:
diff changeset
   516
		}
hgs
parents:
diff changeset
   517
	iClient.RemoveBrandsL( aApplicationId );
hgs
parents:
diff changeset
   518
	}
hgs
parents:
diff changeset
   519
hgs
parents:
diff changeset
   520
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   521
// CBSUpdater::RegisterObserverL()
hgs
parents:
diff changeset
   522
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   523
//
hgs
parents:
diff changeset
   524
void CBSUpdater:: RegisterObserverL( MBSBackupRestoreStateObserver* aBackupObserver )
hgs
parents:
diff changeset
   525
{
hgs
parents:
diff changeset
   526
	iClient.RegisterObserverL(NULL, aBackupObserver) ;
hgs
parents:
diff changeset
   527
}
hgs
parents:
diff changeset
   528
hgs
parents:
diff changeset
   529
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   530
// CBSUpdater::UnRegisterObserverL()
hgs
parents:
diff changeset
   531
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   532
//
hgs
parents:
diff changeset
   533
void CBSUpdater:: UnRegisterObserverL( MBSBackupRestoreStateObserver* aObserver )
hgs
parents:
diff changeset
   534
{
hgs
parents:
diff changeset
   535
	iClient.UnRegisterObserverL(NULL, aObserver) ;
hgs
parents:
diff changeset
   536
}
hgs
parents:
diff changeset
   537
hgs
parents:
diff changeset
   538
//  END OF FILE
hgs
parents:
diff changeset
   539