locationrequestmgmt/networkrequesthandler/src/EPos_PosCommonPrivacyResources.cpp
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // INCLUDE FILES
       
    15 // #ifdef _DEBUG
       
    16 // #include <lbs/epos_cpostrace.h>
       
    17 // #endif
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #include    "EPos_PosCommonPrivacyResources.h"
       
    24 #include    "EPos_PrivacyServerDebugPanic.h"
       
    25 
       
    26 // GLOBAL VARIABLE
       
    27 CPosCommonPrivacyResources* gResources = NULL;
       
    28 
       
    29 // CONSTANTS
       
    30 const TInt KPosRequestIdShift = 14;
       
    31 
       
    32 // ================= LOCAL FUNCTIONS =======================
       
    33 
       
    34 // ---------------------------------------------------------
       
    35 // Static Returns the privacy common resources stored in TLS
       
    36 // Returns: NULL: Resources not installed
       
    37 //          other values: A pointer to the resources
       
    38 // ---------------------------------------------------------
       
    39 //
       
    40 CPosCommonPrivacyResources* Static()
       
    41     {
       
    42     return gResources;
       
    43     }
       
    44 
       
    45 // ================= MEMBER FUNCTIONS =======================
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // PosCommonPrivacyResources::Install
       
    49 //
       
    50 // (other items were commented in a header).
       
    51 // ---------------------------------------------------------
       
    52 //
       
    53 TInt PosCommonPrivacyResources::Install()
       
    54     {
       
    55     if (gResources)
       
    56         {
       
    57         return KErrNone;
       
    58         }
       
    59 
       
    60     gResources = new CPosCommonPrivacyResources();
       
    61 
       
    62     if (!gResources)
       
    63         {
       
    64         return KErrNoMemory;
       
    65         }
       
    66 
       
    67     //Make a request id
       
    68     TTime now;
       
    69     now.UniversalTime();
       
    70     TInt64 requestId64 = now.Int64() >> KPosRequestIdShift;
       
    71     TUint low = I64LOW(requestId64);
       
    72     Static()->iLastAssignedRequestId = ~(~low | 0x80000000);
       
    73 
       
    74     return KErrNone;
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------
       
    78 // PosCommonPrivacyResources::Installed
       
    79 //
       
    80 // (other items were commented in a header).
       
    81 // ---------------------------------------------------------
       
    82 //
       
    83 TBool PosCommonPrivacyResources::Installed()
       
    84     {
       
    85     return (Static()) ? ETrue : EFalse;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------
       
    89 // PosCommonPrivacyResources::Uninstall
       
    90 //
       
    91 // (other items were commented in a header).
       
    92 // ---------------------------------------------------------
       
    93 //
       
    94 void PosCommonPrivacyResources::Uninstall()
       
    95     {
       
    96     delete (gResources);
       
    97     gResources = NULL;
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------
       
   101 // PosCommonPrivacyResources::DialogCtrl
       
   102 //
       
   103 // (other items were commented in a header).
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 CPosDialogCtrl* PosCommonPrivacyResources::DialogCtrl()
       
   107     {
       
   108     return Static()->iDialogCtrl;
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------
       
   112 // PosCommonPrivacyResources::SetDialogCtrl
       
   113 //
       
   114 // (other items were commented in a header).
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 void PosCommonPrivacyResources::SetDialogCtrl(
       
   118     CPosDialogCtrl* aDialogCtrl)
       
   119     {
       
   120     Static()->iDialogCtrl = aDialogCtrl;
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------
       
   124 // PosCommonPrivacyResources::GetNewRequestId
       
   125 //
       
   126 // (other items were commented in a header).
       
   127 // ---------------------------------------------------------
       
   128 //
       
   129 TInt PosCommonPrivacyResources::GetNewRequestId()
       
   130     {
       
   131     // A request id may never be less than 1. Starting over if reaching limit.
       
   132     //
       
   133     if (Static()->iLastAssignedRequestId == KMaxTInt)
       
   134         {
       
   135         Static()->iLastAssignedRequestId = 0;
       
   136         }
       
   137     return ++Static()->iLastAssignedRequestId;
       
   138     }
       
   139 
       
   140 /*
       
   141 #ifdef _DEBUG
       
   142 
       
   143 void PosCommonPrivacyResources::SetupTraceL()
       
   144     {
       
   145     Static()->iTrace = CPosTrace::NewL();
       
   146     }
       
   147 
       
   148 void PosCommonPrivacyResources::TearDownTrace()
       
   149     {
       
   150     if (Static())
       
   151         {
       
   152         delete Static()->iTrace;
       
   153         Static()->iTrace = NULL;
       
   154         }
       
   155     }
       
   156 
       
   157 void PosCommonPrivacyResources::Trace(const TDesC& aDescription,
       
   158                    const TDesC& aFilename,
       
   159                    const TInt aLineNumber)
       
   160     {
       
   161     if (Static() && Static()->iTrace)
       
   162         {
       
   163         TRAPD(err, Static()->iTrace->TraceL(
       
   164             aDescription, aFilename, aLineNumber));
       
   165         err = err; // avoids compiler warning
       
   166         }
       
   167     }
       
   168 #endif
       
   169 */
       
   170 
       
   171 //  End of File