omadrm/drmengine/dcf/src/DcfCommon.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <e32base.h>
    21 #include <e32base.h>
    22 #include <f32file.h>
    22 #include <f32file.h>
    23 #include "DcfCommon.h"
    23 #include "DcfCommon.h"
    24 #include "Oma1Dcf.h"
    24 #include "Oma1Dcf.h"
    25 #include "Oma2Dcf.h"
    25 #include "oma2dcf.h"
    26 
    26 
    27 // ============================ MEMBER FUNCTIONS ===============================
    27 // ============================ MEMBER FUNCTIONS ===============================
    28 
    28 
    29 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    30 // CDcfCommon::CDcfCommon
    30 // CDcfCommon::CDcfCommon
    31 // 
    31 //
    32 // -----------------------------------------------------------------------------
    32 // -----------------------------------------------------------------------------
    33 //
    33 //
    34 CDcfCommon::CDcfCommon():
    34 CDcfCommon::CDcfCommon():
    35     iData(NULL),
    35     iData(NULL),
    36     iMimeType(NULL),
    36     iMimeType(NULL),
    44     {
    44     {
    45     }
    45     }
    46 
    46 
    47 // -----------------------------------------------------------------------------
    47 // -----------------------------------------------------------------------------
    48 // CDcfCommon::ConstructL
    48 // CDcfCommon::ConstructL
    49 // 
    49 //
    50 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    51 //
    51 //
    52 void CDcfCommon::ConstructL(
    52 void CDcfCommon::ConstructL(
    53     const RFile& aFile)
    53     const RFile& aFile)
    54     {
    54     {
    56     iFile.Size(iLength);
    56     iFile.Size(iLength);
    57     }
    57     }
    58 
    58 
    59 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    60 // CDcfCommon::NewL
    60 // CDcfCommon::NewL
    61 // 
    61 //
    62 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    63 //
    63 //
    64 EXPORT_C CDcfCommon* CDcfCommon::NewL(
    64 EXPORT_C CDcfCommon* CDcfCommon::NewL(
    65     const RFile& aFile)
    65     const RFile& aFile)
    66     {
    66     {
    82     return self;
    82     return self;
    83     }
    83     }
    84 
    84 
    85 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    86 // CDcfCommon::NewL
    86 // CDcfCommon::NewL
    87 // 
    87 //
    88 // -----------------------------------------------------------------------------
    88 // -----------------------------------------------------------------------------
    89 //
    89 //
    90 EXPORT_C CDcfCommon* CDcfCommon::NewL(
    90 EXPORT_C CDcfCommon* CDcfCommon::NewL(
    91     const TDesC& aFileName,
    91     const TDesC& aFileName,
    92     RFs* aFs)
    92     RFs* aFs)
    93     {
    93     {
    94     RFs* fs = NULL;
    94     RFs* fs = NULL;
    95     RFile file;
    95     RFile file;
    96     TInt r = KErrNone;
    96     TInt r = KErrNone;
    97     CDcfCommon* self = NULL;
    97     CDcfCommon* self = NULL;
    98     
    98 
    99     if (aFs == NULL)
    99     if (aFs == NULL)
   100         {
   100         {
   101         fs = new RFs();
   101         fs = new RFs();
   102         User::LeaveIfNull(fs);
   102         User::LeaveIfNull(fs);
   103         CleanupStack::PushL(fs);
   103         CleanupStack::PushL(fs);
   104         User::LeaveIfError(fs->Connect());
   104         User::LeaveIfError(fs->Connect());
   105         }
   105         }
   106     else 
   106     else
   107         {
   107         {
   108         fs = aFs;
   108         fs = aFs;
   109         }
   109         }
   110     
   110 
   111 	r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareReadersOrWriters );
   111     r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareReadersOrWriters );
   112     if( r == KErrInUse )
   112     if( r == KErrInUse )
   113         {
   113         {
   114     	r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareAny);        
   114         r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareAny);
   115 
   115 
   116 	    if (r == KErrInUse)
   116         if (r == KErrInUse)
   117 	        {
   117             {
   118     	    r = file.Open(*fs, aFileName, EFileStream | EFileRead |
   118             r = file.Open(*fs, aFileName, EFileStream | EFileRead |
   119     	        EFileShareReadersOnly);
   119                 EFileShareReadersOnly);
   120 	        }
   120             }
   121         }
   121         }
   122 	if(r == KErrNone)
   122     if(r == KErrNone)
   123 	    {
   123         {
   124 	    CleanupClosePushL(file);
   124         CleanupClosePushL(file);
   125 	    self = NewL(file);
   125         self = NewL(file);
   126 	    CleanupStack::PopAndDestroy();
   126         CleanupStack::PopAndDestroy();
   127 	    }
   127         }
   128 
   128 
   129     if (aFs == NULL)
   129     if (aFs == NULL)
   130         {
   130         {
   131         fs->Close();
   131         fs->Close();
   132         CleanupStack::PopAndDestroy();
   132         CleanupStack::PopAndDestroy();
   134     return self;
   134     return self;
   135     }
   135     }
   136 
   136 
   137 // -----------------------------------------------------------------------------
   137 // -----------------------------------------------------------------------------
   138 // CDcfCommon::NewL
   138 // CDcfCommon::NewL
   139 // 
   139 //
   140 // -----------------------------------------------------------------------------
   140 // -----------------------------------------------------------------------------
   141 //
   141 //
   142 EXPORT_C CDcfCommon::~CDcfCommon()
   142 EXPORT_C CDcfCommon::~CDcfCommon()
   143     {
   143     {
   144     delete iData;
   144     delete iData;
   154         }
   154         }
   155     }
   155     }
   156 
   156 
   157 // -----------------------------------------------------------------------------
   157 // -----------------------------------------------------------------------------
   158 // CDcfCommon::
   158 // CDcfCommon::
   159 // 
   159 //
   160 // -----------------------------------------------------------------------------
   160 // -----------------------------------------------------------------------------
   161 //
   161 //
   162 TInt CDcfCommon::CheckUniqueId(const TDesC& aUniqueId)
   162 TInt CDcfCommon::CheckUniqueId(const TDesC& aUniqueId)
   163 	{
   163     {
   164 	if (aUniqueId.Compare(KDefaultContentObject) == 0)
   164     if (aUniqueId.Compare(KDefaultContentObject) == 0)
   165 	    {
   165         {
   166 	    return 0;
   166         return 0;
   167 	    }
   167         }
   168 	else
   168     else
   169 	    {
   169         {
   170 	    return KErrNotFound;
   170         return KErrNotFound;
   171 	    }
   171         }
   172 	}
   172     }
   173 
   173 
   174 //  End of File  
   174 //  End of File