Creating Transfer Types

To transfer data between the Backup Engine and the backup server, a particular type of conn::CSBGenericTransferType must be created.

Introduction

The conn::CSBEClient uses conn::CSBGenericTransferType to request (for backup) or supply (for restore) data. One of the following three derived classes must be created to transfer data.

  • conn::CSBSIDTransferType transfers data of the owner whose type is conn::ESIDDerivedType. Data owners of this type are the common applications or servers built into the ROM.

    You can specify the creation of passive data, active data or snapshot data transfer type by passing a conn::TTransferDataType parameter value to the CSBSIDTransferType::NewL() function. For example, passing EActiveSnapshotData to CSBSIDTransferType:NewL() creates an active snapshot transfer type.

  • conn::CSBPackageTransferType transfers data of the owner whose type is conn::EPackageDerivedType. Data owners of this type are usually installed through SIS files. Installing a package may install may install several applications (data owners). Each package is identified by a package ID while each data owner is identified by a package ID, a package name and an SID.

    Packages are often installed to a system drive, their data and snapshots are referred to as system data and system data snapshots.

  • conn::CSBJavaId transfers data of the owner whose type is conn::EJavaDerivedType. Data owners of this type are Java applications.

Procedure

Create an array of a particular type, for example passive data for all data owners. Then go through the array to create the transfer types.

The following example shows how to create the conn::CSBPackageTransferType. You can further specify to create the data or snapshots.

/**
Each data owner in iDataOwners is a CDataOwnerInfo object, the following creates 
CSBGenericTransferTypes based on the TPackageDataType passed. 
@param aTransferTypes - Array of package transfer types.
@param aPkgDataType - system data or system data snapshot.
*/

void::GeneratePIDTransferTypesL(
           RPointerArray<CSBGenericTransferType>& aTransferTypes,
           TPackageDataType aPkgDataType)
{

    aTransferTypes.ResetAndDestroy();
    TUid id;

    //need array to avoid duplications
    RArray<TUid> uidArray;
    CleanupClosePushL(uidArray);

    //One transfer type is created for each drive 
    //on which the data owner has data.
    TInt length = iDriveList.Length();
    for (TInt driveCount = 0; driveCount < length; driveCount++)
       {
       if (iDriveList[driveCount])
              {
              TInt count = iDataOwners.Count();
              for (TInt i = 0; i < count; i++)
                    {
                    switch (iDataOwners[i]->Identifier().DerivedTypeL())
                       {
                        case EPackageDerivedType:
                         if (iDataOwners[i]->CommonSettings() & EHasSystemFiles)
                               {
                               //Create CSBPackageId for each data owner in the package
                               CSBPackageId* pkgId = 
                                  CSBPackageId::NewL(&(iDataOwners[i]->Identifier()));
                               CleanupStack::PushL(pkgId);
                                          
                               id = pkgId->PackageIdL();
                               if (uidArray.Find(id) == KErrNotFound)
                                  {
                                  
                                  //Create the package transfer type based on the 
                                  //aPkgDataType parameter value passed in, 
                                  //system data or snapshot.
                                  CSBPackageTransferType* idType = 
                                      CSBPackageTransferType::NewL(
                                                                   id,
                                                                   TDriveNumber(driveCount), 
                                                                   aPkgDataType  
                                                                  );
                                  CleanupStack::PushL(idType);
                                  aTransferTypes.AppendL(idType);
                                  CleanupStack::Pop(idType);

                                  //add to uid array
                                  uidArray.AppendL(id);
                                  }
                               CleanupStack::PopAndDestroy(pkgId);      
                               } //if
                        break;
                       } // switch
                    } //for              
                } //if 
          } //for

CleanupStack::PopAndDestroy(&uidArray);
}