sdkcreationmw/sdkexamples/cppexamples/S60Ex/helperfunctions/eikonenvironment.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) 2004, 2006 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
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
// INCLUDES
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
#include <eikappui.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
#include <eikenv.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
#include <eikapp.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
#include <s32file.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
#include <aknnotewrappers.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
#include "EikonEnvironment.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
// ============================ MEMBER FUNCTIONS ==============================
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
// NEikonEnvironment::AppFullName()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
// Returns full name of the application.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
TFileName NEikonEnvironment::AppFullName()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
    return EikAppUi().Application()->AppFullName();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
// NEikonEnvironment::ApplicationDriveAndPath()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
// Returns the drive and path of the application.
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
TFileName NEikonEnvironment::ApplicationDriveAndPath()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
    TParse parse;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
//On WINS the application is on the z drive
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
#ifdef __WINS__
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
    TFileName appfullname = AppFullName();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
    _LIT( KDriveC,"c:" ); //create literal
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
    parse.Set(KDriveC, &appfullname, NULL);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
#else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
    parse.Set(AppFullName(), NULL, NULL);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
#endif
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
    return parse.DriveAndPath();
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
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
// NEikonEnvironment::AddPath()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
// Returns the drive, path and filename.
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
TFileName NEikonEnvironment::AddPath( const TDesC& aFileName )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
//Check that we have not been sent a file name with the drive included
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
#ifdef _DEBUG
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
    TParse theFile;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
    theFile.Set( aFileName, NULL, NULL );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
    ASSERT( theFile.Drive().Length() == 0 );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
#endif
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
    TParse thePath;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
    thePath.Set( ApplicationDriveAndPath(),  &aFileName,  NULL );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
    return thePath.FullName();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
// NEikonEnvironment::EikEnv()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
// Return a reference to the CEikonEnv
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
CEikonEnv& NEikonEnvironment::EikEnv()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
    return *CEikonEnv::Static();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
// NEikonEnvironment::EikAppUi()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
// Return a reference to the CEikAppUi
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
CEikAppUi& NEikonEnvironment::EikAppUi()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
    return *( EikEnv().EikAppUi() );
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
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
// NEikonEnvironment::EikDocument()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
// Return a reference to CEikDocument.
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
CEikDocument& NEikonEnvironment::EikDocument()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
    return *( EikAppUi().Document() );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   109
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   110
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   111
// NEikonEnvironment::AddToStackL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   112
// Add a control to the control stack.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   113
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   114
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   115
void NEikonEnvironment::AddToStackL( CCoeControl& aControl,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   116
                                     TInt aPriority,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   117
                                     TInt aStackingFlags )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   118
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   119
    RemoveFromStack( aControl );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   120
    EikAppUi().AddToStackL( &aControl, aPriority, aStackingFlags );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   121
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   122
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   123
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   124
// NEikonEnvironment::AddToStackL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   125
// Add a control to the control stack.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   126
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   127
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   128
void NEikonEnvironment::AddToStackL( CCoeControl& aControl )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   129
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   130
    RemoveFromStack( aControl );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   131
    EikAppUi().AddToStackL( &aControl );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   132
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   133
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   134
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   135
// NEikonEnvironment::RemoveFromStack()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   136
// Remove a control from the control stack.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   137
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   138
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   139
void NEikonEnvironment::RemoveFromStack( CCoeControl& aControl )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   140
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   141
    EikAppUi().RemoveFromStack( &aControl );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   142
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   143
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   144
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   145
// NEikonEnvironment::MessageBox()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   146
// Display a message box
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   147
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   148
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   149
void NEikonEnvironment::MessageBox( const TDesC&  aMessage )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   150
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   151
    TRAPD( err,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   152
          CAknInformationNote* informationNote = new (
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   153
                                                 ELeave ) CAknInformationNote;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   154
          informationNote->ExecuteLD( aMessage );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   155
          );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   156
    if ( err != KErrNone )
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   157
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   158
        _LIT( KHelperFunctionsPanic, "Helper" );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   159
        User::Panic( KHelperFunctionsPanic, 1 );
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   160
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   161
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   162
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   163
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   164
// NEikonEnvironment::FlushWindowServer()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   165
// Flush the windows server to ensure all changes to the
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   166
// display are reflected on the screen
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   167
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   168
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   169
void NEikonEnvironment::FlushWindowServer()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   170
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   171
    CCoeEnv::Static()->WsSession().Flush();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   172
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   173
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   174
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   175
// NEikonEnvironment::TheRFs()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   176
// The eikon frameworks file server connection.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   177
// ----------------------------------------------------------------------------
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   178
//
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   179
RFs& NEikonEnvironment::TheRFs()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   180
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   181
    return CCoeEnv::Static()->FsSession();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   182
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   183
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   184
// End of File