bluetoothengine/btnotif/src/btnenterpriseitsecurityinfonotifier.cpp
branchRCL_3
changeset 23 9386f31cc85b
child 24 269724087bed
equal deleted inserted replaced
22:613943a21004 23:9386f31cc85b
       
     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:  Bluetooth visibility timeout notifier class.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <BTNotif.rsg>								// Own resources
       
    20 #include "btnenterpriseitsecurityinfonotifier.h"	// Own class definition
       
    21 #include "btNotifDebug.h"							// Debugging macros
       
    22 #include <tulstringresourcereader.h>
       
    23 #include <e32cmn.h>
       
    24 #include <dcmo.rsg>
       
    25 
       
    26 _LIT(KDcmoResourceFileName, "z:dcmo.rsc");
       
    27 _LIT(KNewLine, "\n");
       
    28 
       
    29 //"Bluetooth" is 9 characters long
       
    30 const TInt KDefaultBluetoothStringLength = 9;
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 
       
    34 // ----------------------------------------------------------
       
    35 // CBTEnterpriseItSecurityInfoNotifier::NewL
       
    36 // Two-phased constructor.
       
    37 // ----------------------------------------------------------
       
    38 //
       
    39 CBTEnterpriseItSecurityInfoNotifier* CBTEnterpriseItSecurityInfoNotifier::NewL()
       
    40     {
       
    41     CBTEnterpriseItSecurityInfoNotifier* self=new (ELeave) CBTEnterpriseItSecurityInfoNotifier();
       
    42     CleanupStack::PushL(self);
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop(self);
       
    45     return self;
       
    46     }
       
    47 
       
    48 // ----------------------------------------------------------
       
    49 // CBTEnterpriseItSecurityInfoNotifier::CBTEnterpriseItSecurityInfoNotifier
       
    50 // C++ default constructor can NOT contain any code, that
       
    51 // might leave.
       
    52 // ----------------------------------------------------------
       
    53 //
       
    54 CBTEnterpriseItSecurityInfoNotifier::CBTEnterpriseItSecurityInfoNotifier() 
       
    55     {
       
    56     }
       
    57 
       
    58 // ----------------------------------------------------------
       
    59 // Destructor
       
    60 // ----------------------------------------------------------
       
    61 //
       
    62 CBTEnterpriseItSecurityInfoNotifier::~CBTEnterpriseItSecurityInfoNotifier()
       
    63     {
       
    64     Cancel();
       
    65     }
       
    66 
       
    67 // ----------------------------------------------------------
       
    68 // CBTEnterpriseItSecurityInfoNotifier::RegisterL
       
    69 // Register notifier.
       
    70 // ----------------------------------------------------------
       
    71 //
       
    72 CBTEnterpriseItSecurityInfoNotifier::TNotifierInfo CBTEnterpriseItSecurityInfoNotifier::RegisterL()
       
    73     {
       
    74     iInfo.iUid = KBTEnterpriseItSecurityInfoNotifierUid;
       
    75     iInfo.iChannel = KBTEnterpriseItSecurityInfoNotifierUid;
       
    76     iInfo.iPriority = ENotifierPriorityHigh;
       
    77     return iInfo;
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------
       
    81 // CBTEnterpriseItSecurityInfoNotifier::StartL
       
    82 // Synchronic notifier launch. Contructs and shows a global
       
    83 // note when temp visibility expire, no parameters need here.
       
    84 // ----------------------------------------------------------
       
    85 //
       
    86 TPtrC8 CBTEnterpriseItSecurityInfoNotifier::StartL(const TDesC8& /*aBuffer*/)
       
    87     {
       
    88     FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::StartL()"));
       
    89     
       
    90     ShowNoteAndCompleteL();
       
    91 
       
    92 	FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::StartL() completed"));
       
    93     return TPtrC8(KNullDesC8);
       
    94     }
       
    95 
       
    96 // ----------------------------------------------------------
       
    97 // CBTEnterpriseItSecurityInfoNotifier::GetParamsL
       
    98 // Mandatory for BT Notifiers when using asynchronous launch. 
       
    99 // ----------------------------------------------------------
       
   100 //
       
   101 void CBTEnterpriseItSecurityInfoNotifier::GetParamsL(const TDesC8& /*aBuffer*/,
       
   102 										 TInt /*aReplySlot*/,
       
   103 										 const RMessagePtr2& /*aMessage*/)
       
   104     {
       
   105     //nothing to do here
       
   106     }
       
   107 
       
   108 // ----------------------------------------------------------
       
   109 // CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndCompleteL
       
   110 // Shows the notifier in backround 
       
   111 // ----------------------------------------------------------
       
   112 //
       
   113 void CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndCompleteL()
       
   114 	{
       
   115 	FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndComplete()"));
       
   116 	
       
   117 	//get full path to the DCMO resource file
       
   118 	TParse* parser = new (ELeave) TParse;
       
   119 	parser->Set(KDcmoResourceFileName(), &KDC_RESOURCE_FILES_DIR, NULL);
       
   120 	CleanupStack::PushL(parser);
       
   121 	TFileName* fileName = new (ELeave) TFileName;
       
   122 	*fileName = parser->FullName();
       
   123 	CleanupStack::PopAndDestroy(parser);
       
   124 	CleanupStack::PushL(fileName);
       
   125 	
       
   126 	//create the resource reader object that we need to use several times
       
   127 	CTulStringResourceReader* reader = CTulStringResourceReader::NewL(*fileName);
       
   128 	CleanupStack::PushL(reader);
       
   129 	
       
   130 	//get pointer to the message part of the notifier
       
   131 	TPtrC resourceString;
       
   132 	resourceString.Set(reader->ReadResourceString(R_DM_RUN_TIME_VAR_DISABLE));
       
   133 
       
   134 	//create descriptor with a max length to fit the localised "disabled" text + new line + "Bluetooth"
       
   135 	RBuf content;
       
   136 	content.CreateL(resourceString.Length() + KNewLine().Length() + KDefaultBluetoothStringLength);
       
   137 	CleanupClosePushL(content);
       
   138 	
       
   139 	//add resource string and new line character to the content descriptor
       
   140 	content.Append(resourceString);	
       
   141 	content.Append(KNewLine());
       
   142 	
       
   143 	//get pointer to the Bluetooth name part of the notifier (can't assume this is actually "Bluetooth" in all languages)
       
   144 	resourceString.Set(reader->ReadResourceString(R_DM_RUN_TIME_VAR_BLUETOOTH));
       
   145 	
       
   146 	//check that the resource string will fit into the content descriptor
       
   147 	TInt requiredLength = content.Length() + resourceString.Length();
       
   148 	if (requiredLength > content.MaxLength())
       
   149 		{
       
   150 		//allocate more space in the content descriptor
       
   151 		content.ReAllocL(requiredLength);
       
   152 		}
       
   153 	
       
   154 	//add resource string to the content descriptor
       
   155 	content.Append(resourceString);	
       
   156 	
       
   157 	//display the notifier and complete
       
   158 	iNotifUiUtil->ShowInfoNoteL(content, ECmdBTnotifUnavailable);
       
   159 	CompleteMessage(KErrNone);
       
   160 	
       
   161 	//pop and destroy the content descriptor, resource reader and file name
       
   162 	CleanupStack::PopAndDestroy(3, fileName);
       
   163 	
       
   164 	FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndComplete() complete"));
       
   165 	}
       
   166 
       
   167 void CBTEnterpriseItSecurityInfoNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/)
       
   168     {
       
   169     //nothing to do here
       
   170     }
       
   171 
       
   172 // End of File