sdkcreationmw/sdkexamples/cppexamples/S60Ex/helperfunctions/IconFileProvider.cpp
author Shabe Razvi <shaber@symbian.org>
Thu, 04 Nov 2010 17:22:05 +0000
changeset 4 b3b823debf08
parent 0 b26acd06ea60
permissions -rw-r--r--
Workaround for Bug 3917 - CWinsockInterface::DataSent calls NotifyDataSent which is not implemented.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     1
/*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     2
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     3
* All rights reserved.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     8
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     9
* Initial Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    11
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    12
* Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    13
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    14
* Description: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    15
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    16
*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    17
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    18
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    19
#include "IconFileProvider.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
// ============================ MEMBER FUNCTIONS ===============================
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
// CIconFileProvider::CIconFileProvider()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
// C++ default constructor.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
CIconFileProvider::CIconFileProvider(RFs aSession) : iSession(aSession)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
// CIconFileProvider::NewL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
// Two-phased constructor.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
CIconFileProvider* CIconFileProvider::NewL(RFs aSession, const TDesC& aFilename)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
    CIconFileProvider* self = new (ELeave) CIconFileProvider(aSession);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
    CleanupStack::PushL(self);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
    self->ConstructL(aFilename);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
    CleanupStack::Pop(); // self
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
    return self;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
// CIconFileProvider::ConstructL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
// 2nd phase constructor
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
void CIconFileProvider::ConstructL( const TDesC& aFilename)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
    iFilename = aFilename.AllocL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
// CIconFileProvider::~CIconFileProvider()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
// Destructor
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
CIconFileProvider::~CIconFileProvider()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
    delete iFilename;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
// CIconFileProvider::RetrieveIconFileHandleL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
// Returns an open file handle to the icon file.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
void CIconFileProvider::RetrieveIconFileHandleL( RFile& aFile,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
                                                const TIconFileType aType )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
    // MAknIconFileProvider will by default try to open files that
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
	// have .mif extension first. If in case of this application, only the
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
	// file handle of mbm-file is passed to framework,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
	// MAknIconFileProvider result will be KErrArgument. This is solved by
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
	// giving the correct file extension determined by function parameter
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
	// aType.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
	//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
    TFileName filename;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
    filename = iFilename->Des().Left(iFilename->Length()-3);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
    if (aType == EMifFile)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
        _LIT(KMif, "mif");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
        filename.Append(KMif);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
    else // mbm
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
        _LIT(KMbm, "mbm");
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
        filename.Append(KMbm);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
	User::LeaveIfError(aFile.Open(iSession, filename, EFileShareAny));
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
// CIconFileProvider::Finished()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
// With this method, AknIcon framework informs that it does not use this
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
// MAknIconFileProvider instance any more.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
// -----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   105
void CIconFileProvider::Finished()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108