os/kernelhwsrv/userlibandfileserver/fileserver/automounter/automounter.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
sl@0
    15
/*
sl@0
    16
    @file
sl@0
    17
    @internalTechnology
sl@0
    18
sl@0
    19
    "fs_auto_mounter" filesystem classes definition
sl@0
    20
*/
sl@0
    21
sl@0
    22
sl@0
    23
#ifndef AUTOMOUNTER_FILESYSTEM_H
sl@0
    24
#define AUTOMOUNTER_FILESYSTEM_H
sl@0
    25
sl@0
    26
#include "filesystem_utils.h"
sl@0
    27
#include <f32fsys.h>
sl@0
    28
#include <f32dbg.h>
sl@0
    29
sl@0
    30
sl@0
    31
IMPORT_C TUint32 DebugRegister();
sl@0
    32
sl@0
    33
//-- define this for having logs disregarding DebugRegister() settings
sl@0
    34
//#define FORCE_LOGS
sl@0
    35
sl@0
    36
sl@0
    37
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
    38
//----------------- DEBUG mode -----------------
sl@0
    39
sl@0
    40
#ifndef FORCE_LOGS 
sl@0
    41
    #define __PRINT(t)          {if (DebugRegister()&KFSYS) RDebug::Print(t);}
sl@0
    42
    #define __PRINT1(t,a)       {if (DebugRegister()&KFSYS) RDebug::Print(t,a);}
sl@0
    43
    #define __PRINT2(t,a,b)     {if (DebugRegister()&KFSYS) RDebug::Print(t,a,b);}
sl@0
    44
    #define __PRINT3(t,a,b,c)   {if (DebugRegister()&KFSYS) RDebug::Print(t,a,b,c);}
sl@0
    45
    #define __PRINT4(t,a,b,c,d) {if (DebugRegister()&KFSYS) RDebug::Print(t,a,b,c,d);}
sl@0
    46
#else
sl@0
    47
    #define __PRINT(t)          {RDebug::Print(t);}
sl@0
    48
    #define __PRINT1(t,a)       {RDebug::Print(t,a);}
sl@0
    49
    #define __PRINT2(t,a,b)     {RDebug::Print(t,a,b);}
sl@0
    50
    #define __PRINT3(t,a,b,c)   {RDebug::Print(t,a,b,c);}
sl@0
    51
    #define __PRINT4(t,a,b,c,d) {RDebug::Print(t,a,b,c,d);}
sl@0
    52
#endif
sl@0
    53
sl@0
    54
#define DBG_STATEMENT(text) text
sl@0
    55
sl@0
    56
#else
sl@0
    57
//----------------- RELEASE mode -----------------
sl@0
    58
#define __PRINT(t)
sl@0
    59
#define __PRINT1(t,a)
sl@0
    60
#define __PRINT2(t,a,b)
sl@0
    61
#define __PRINT3(t,a,b,c)
sl@0
    62
#define __PRINT4(t,a,b,c,d)
sl@0
    63
#define __PRINT8BIT1(t,a)
sl@0
    64
#define __PRINT1TEMP(t,a)
sl@0
    65
sl@0
    66
#define DBG_STATEMENT(text)
sl@0
    67
sl@0
    68
#endif //#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
    69
sl@0
    70
sl@0
    71
//#######################################################################################################################################
sl@0
    72
//#     constants definitions here
sl@0
    73
//#######################################################################################################################################
sl@0
    74
sl@0
    75
sl@0
    76
sl@0
    77
//-----------------------------------------------------------------------------
sl@0
    78
sl@0
    79
/**
sl@0
    80
Internal fault codes for Automounter.fsy
sl@0
    81
*/
sl@0
    82
enum TFault
sl@0
    83
    {
sl@0
    84
    ENotImplemented,
sl@0
    85
    EWrongDriveAttributes,
sl@0
    86
    EPluginInitialise,
sl@0
    87
    EFileSysNotAdded,
sl@0
    88
    EWrongConfiguration,
sl@0
    89
    EIncompatibleFileSystems,
sl@0
    90
sl@0
    91
    EMustNotBeCalled
sl@0
    92
sl@0
    93
    };
sl@0
    94
sl@0
    95
//-----------------------------------------------------------------------------
sl@0
    96
sl@0
    97
void Fault(TFault aFault);
sl@0
    98
sl@0
    99
sl@0
   100
//-----------------------------------------------------------------------------
sl@0
   101
/**
sl@0
   102
    This class is a container for child file system names that are supported by automounter.
sl@0
   103
    Child FS names are stored in Upper Case to enable simple FSName hash calculations.
sl@0
   104
    The names must be unique.
sl@0
   105
*/
sl@0
   106
class XStringArray
sl@0
   107
    {
sl@0
   108
 public:
sl@0
   109
    XStringArray();
sl@0
   110
    ~XStringArray();
sl@0
   111
sl@0
   112
    void Reset();
sl@0
   113
    const TDesC& operator[](TUint aIndex) const;
sl@0
   114
    TInt Append(const TDesC& aString);
sl@0
   115
    TUint Count() const {return iStrings.Count();}
sl@0
   116
    TUint32 GetStringHash(TUint aIndex) const;
sl@0
   117
sl@0
   118
sl@0
   119
 private:
sl@0
   120
    XStringArray(const XStringArray&);
sl@0
   121
    XStringArray& operator=(const XStringArray&);
sl@0
   122
sl@0
   123
    /** panic codes */
sl@0
   124
    enum TPanicCode
sl@0
   125
        {
sl@0
   126
        EIndexOutOfRange, ///< index out of range
sl@0
   127
        ENotImplemented,  ///< functionality isn't implemented
sl@0
   128
        };
sl@0
   129
sl@0
   130
    void Panic(TPanicCode aPanicCode) const;
sl@0
   131
sl@0
   132
 private:
sl@0
   133
    RPointerArray<HBufC> iStrings;
sl@0
   134
    
sl@0
   135
    };
sl@0
   136
sl@0
   137
sl@0
   138
//-----------------------------------------------------------------------------
sl@0
   139
sl@0
   140
/**
sl@0
   141
    File system class definition
sl@0
   142
*/
sl@0
   143
class CAutoMounterFileSystem : public CFileSystem, CFileSystem::MFileSystemExtInterface
sl@0
   144
    {
sl@0
   145
public:
sl@0
   146
    static CAutoMounterFileSystem* New();
sl@0
   147
    ~CAutoMounterFileSystem();
sl@0
   148
public:
sl@0
   149
    
sl@0
   150
    //-- pure virtual interface implementation, overrides from CFileSystem
sl@0
   151
    TInt Install();
sl@0
   152
    CMountCB* NewMountL() const;
sl@0
   153
    CFileCB* NewFileL() const;
sl@0
   154
    CDirCB* NewDirL() const;
sl@0
   155
    CFormatCB* NewFormatL() const;
sl@0
   156
    
sl@0
   157
    //-- non-pure virtual interface, overrides from CFileSystem
sl@0
   158
#ifdef _DEBUG
sl@0
   159
    TInt Remove();
sl@0
   160
    TBool QueryVersionSupported(const TVersion& aVer) const;
sl@0
   161
#endif
sl@0
   162
    
sl@0
   163
    TBool IsExtensionSupported() const;
sl@0
   164
    TInt DefaultPath(TDes& aPath) const;
sl@0
   165
    TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
sl@0
   166
    
sl@0
   167
    
sl@0
   168
    
sl@0
   169
    
sl@0
   170
protected:
sl@0
   171
    CAutoMounterFileSystem();
sl@0
   172
sl@0
   173
    TInt TryMountFilesystem(TDrive* apDrive, CMountCB** apMount, CFileSystem** apFS);
sl@0
   174
sl@0
   175
sl@0
   176
    //-------------------------------
sl@0
   177
    virtual CMountCB* NewMountExL(TDrive* apDrive, CFileSystem** apFileSystem, TBool aForceMount, TUint32 aFsNameHash);
sl@0
   178
    virtual TInt GetSupportedFileSystemName(TInt aFsNumber, TDes& aFsName) const;   
sl@0
   179
sl@0
   180
sl@0
   181
private:
sl@0
   182
    
sl@0
   183
    /** possible states of this object */
sl@0
   184
    enum TState
sl@0
   185
        {
sl@0
   186
        EInvalid = 0,       ///< initial, invalid
sl@0
   187
        ENotInitialised,
sl@0
   188
        EInitialised, 
sl@0
   189
        };
sl@0
   190
sl@0
   191
    inline TState State() const {return iState;}
sl@0
   192
    inline void SetState(TState aState) {iState = aState;}
sl@0
   193
sl@0
   194
    
sl@0
   195
    /** "default child" file system name index in the child names container. "default child" is used in some weir cases, when
sl@0
   196
        it doesn't matter which particular child FS to use, e.g. getting access to the media driver for media unlocking. */
sl@0
   197
    enum {KDefaultFSNo = 0}; 
sl@0
   198
sl@0
   199
sl@0
   200
    CFileSystem* GetChildFileSystem(TUint aIndex) const;
sl@0
   201
    CFileSystem* GetChildFileSysteByNameHash(TUint32 aFsNameHash) const;
sl@0
   202
sl@0
   203
    void InitialiseFileSystem();
sl@0
   204
    TInt DoProcessProxyDriveSupport();
sl@0
   205
sl@0
   206
private:
sl@0
   207
    
sl@0
   208
    TState       iState;    ///< this object current state
sl@0
   209
    XStringArray iFSNames;  ///< child file system names container.
sl@0
   210
sl@0
   211
    };
sl@0
   212
sl@0
   213
sl@0
   214
//-----------------------------------------------------------------------------
sl@0
   215
sl@0
   216
#endif //AUTOMOUNTER_FILESYSTEM_H
sl@0
   217
sl@0
   218
sl@0
   219
sl@0
   220
sl@0
   221
sl@0
   222