landmarksui/msgviewer/src/CLmkMsgViewerDocument.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2002 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:    LandmarksUi Content File -    Provides LM document class methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 // INCLUDE FILES
       
    25 
       
    26 #include <f32file.h>
       
    27 #include "CLmkMsgViewerDocument.h"
       
    28 #include "CLmkMsgViewerAppUi.h"
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 // ----------------------------------------------------------------------------
       
    32 // CLmkMsgViewerDocument::CLmkMsgViewerDocument
       
    33 // ----------------------------------------------------------------------------
       
    34 //
       
    35 CLmkMsgViewerDocument::CLmkMsgViewerDocument( CEikApplication& aApp )
       
    36     : CEikDocument( aApp )
       
    37     {
       
    38     }
       
    39 
       
    40 // ----------------------------------------------------------------------------
       
    41 // CLmkMsgViewerDocument::~CLmkMsgViewerDocument
       
    42 // ----------------------------------------------------------------------------
       
    43 //
       
    44 CLmkMsgViewerDocument::~CLmkMsgViewerDocument()
       
    45     {
       
    46     iLandmarkContentFileHandle.Close();
       
    47     delete iFileFullPath;
       
    48     }
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // CLmkMsgViewerDocument::ConstructL
       
    52 // Symbian 2nd phase constructor can leave.
       
    53 // ----------------------------------------------------------------------------
       
    54 //
       
    55 void CLmkMsgViewerDocument::ConstructL()
       
    56     {
       
    57     }
       
    58 
       
    59 // ----------------------------------------------------------------------------
       
    60 // CLmkMsgViewerDocument::NewL
       
    61 // Two-phased constructor.
       
    62 // ----------------------------------------------------------------------------
       
    63 //
       
    64 CLmkMsgViewerDocument* CLmkMsgViewerDocument::NewL( CEikApplication& aApp )
       
    65     {
       
    66     CLmkMsgViewerDocument* self = new( ELeave ) CLmkMsgViewerDocument( aApp );
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop();
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ----------------------------------------------------
       
    74 // CLmkMsgViewerDocument::CreateAppUiL
       
    75 // constructs CLmkMsgViewerAppUi
       
    76 // ----------------------------------------------------
       
    77 //
       
    78 CEikAppUi* CLmkMsgViewerDocument::CreateAppUiL()
       
    79     {
       
    80     return new( ELeave ) CLmkMsgViewerAppUi;
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CLmkMsgViewerDocument::OpenFileL()
       
    85 // Open document.
       
    86 // -----------------------------------------------------------------------------
       
    87 CFileStore* CLmkMsgViewerDocument::OpenFileL(
       
    88     TBool /*aDoOpen*/,
       
    89     const TDesC& aFilename,
       
    90     RFs& aFs )
       
    91     {
       
    92 	//static_cast<CLmkMsgViewerAppUi*>( iAppUi )->OpenL( aFilename );
       
    93 
       
    94 	// Function is called with Full-path.
       
    95     iIsFileFullPathValid = ETrue;
       
    96     // Store the File's fullpath.
       
    97     iFileFullPath = aFilename.AllocL();
       
    98 
       
    99     // Open File Handle for the file
       
   100     TInt openError = iLandmarkContentFileHandle.Open( aFs, aFilename,
       
   101         EFileShareReadersOnly);
       
   102     if ( openError != KErrNone )
       
   103         {
       
   104         User::Leave( openError );
       
   105         }
       
   106     iIsFileHandleValid = ETrue;
       
   107     return NULL;
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CLmkMsgViewerDocument::OpenFileL()
       
   112 // Open document.
       
   113 // -----------------------------------------------------------------------------
       
   114 
       
   115 void CLmkMsgViewerDocument::OpenFileL(
       
   116     CFileStore*& /* aFileStore */,
       
   117     RFile& aFile)
       
   118     {
       
   119     // Duplicate the file handle
       
   120     // Function is not called with Full-path.
       
   121     iIsFileFullPathValid = EFalse;
       
   122 
       
   123     // File-handle is valid
       
   124     iIsFileHandleValid = ETrue;
       
   125     iLandmarkContentFileHandle.Duplicate(aFile);
       
   126     aFile.Close();
       
   127 	//static_cast<CLmkMsgViewerAppUi*>( iAppUi )->OpenL( aFile );
       
   128     //aFileStore = NULL;
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 //  CLmkMsgViewerDocument::GetLandmarkContentFileHandle
       
   133 // This function is a get function to get the file-handle of the file content.
       
   134 // This is used by AppUI.
       
   135 // Returns: File handle of content by reference .
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 RFile& CLmkMsgViewerDocument::GetLandmarkContentFileHandle()
       
   139     {
       
   140     return iLandmarkContentFileHandle;
       
   141     }
       
   142 
       
   143     // -----------------------------------------------------------------------------
       
   144 // CLmkMsgViewerDocument::IsFileHandleValid()
       
   145 // Used by UI class to check if file's handle is valid
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 TBool CLmkMsgViewerDocument::IsFileHandleValid() const
       
   149     {
       
   150     return (iIsFileHandleValid != NULL);
       
   151     }
       
   152 
       
   153 
       
   154 // End of File