×
Namespaces

Variants
Actions
(Difference between revisions)

Showing a manufacturer disclaimer during the first launch on Symbian

From Nokia Developer Wiki
Jump to: navigation, search
tapla (Talk | contribs)
(New page: __NOTOC__ __NOEDITSECTION__ {|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" |- |'''ID''' ||   |'''Creation date''' || April 25, 2008 |- |'''Pla...)
 
lpvalente (Talk | contribs)
m (Lpvalente -)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
+
[[Category:Files/Data]][[Category:Symbian C++]][[Category:Code Snippet]][[Category:Code Snippet]][[Category:Symbian Signed]][[Category:S60 3rd Edition FP1]][[Category:S60 3rd Edition (initial release)]]
__NOEDITSECTION__
+
{{ArticleMetaData <!-- v1.2 -->
 
+
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|-
+
|devices= Nokia N95 8GB
|'''ID''' || &nbsp;
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|'''Creation date''' || April 25, 2008
+
|platform= S60 3rd Edition
|-
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|'''Platform''' || S60 3rd Edition, MR
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|'''Tested on devices''' || Nokia N95 8GB
+
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
|-
+
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
|'''Category''' || Symbian C++
+
|keywords= RFs, RFile, BaflUtils, CAknMessageQueryDialog, RFs::Connect(), RFile::Open(), RFile::Size(), RFile::Read(), RFile::Close(), BaflUtils::FileExists(), BaflUtils::DeleteFile(), CAknMessageQueryDialog::RunLD()
|'''Subcategory''' || Files/Data
+
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
|}
+
|translated-by= <!-- [[User:XXXX]] -->
 
+
|translated-from-title= <!-- Title only -->
 
+
|translated-from-id= <!-- Id of translated revision -->
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|review-by= <!-- After re-review: [[User:username]] -->
|-
+
|review-timestamp= <!-- After re-review: YYYYMMDD -->
|'''Keywords (APIs, classes, methods, functions):''' RFs, RFile, BaflUtils, CAknMessageQueryDialog, RFs::Connect(), RFile::Open(), RFile::Size(), RFile::Read(), RFile::Close(), BaflUtils::FileExists(), BaflUtils::DeleteFile(), CAknMessageQueryDialog::RunLD()
+
|update-by= <!-- After significant update: [[User:username]]-->
|}
+
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080425
 +
|author= [[User:Tapla]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= Files/Data
 +
|id= CS000935
 +
}}
  
 
==Overview==
 
==Overview==
  
This code snippet demonstrates how to display a manufacturer disclaimer when an application is launched for the first time. This behavior is required at least for VoIP applications that are meant to be sent to Symbian for [http://developer.symbian.com/wiki/display/pub/Symbian+Signed signing].
+
{{Abstract|This code snippet demonstrates how to display a manufacturer disclaimer when an application is launched for the first time. This behavior is required at least for VoIP applications that are meant to be sent to Symbian for [[:Category:Symbian Signed|signing]].}}
  
In practice, the requested behavior is implemented by deleting the disclaimer file after it has been accepted for the first time. Every time the application is run, it is checked whether the file exists or not.
+
In practice, the requested behavior is implemented by deleting the disclaimer file after it has been accepted for the first time. Every time the application is run, it is checked whether or not the file exists.
  
 
This snippet can be self-signed.
 
This snippet can be self-signed.
Line 30: Line 36:
 
==data\disclaimer.txt==
 
==data\disclaimer.txt==
  
Here is an example of the disclaimer text for VoIP applications according to Symbian:
+
Here is an example of the disclaimer text by Symbian for VoIP applications:
  
 
<code>
 
<code>
Line 54: Line 60:
  
 
<code>
 
<code>
LIBRARY bafl.lib  
+
LIBRARY bafl.lib  
 
</code>
 
</code>
  
Line 100: Line 106:
 
         /**
 
         /**
 
         * Shows the disclaimer dialog.
 
         * Shows the disclaimer dialog.
         * @return ETrue if the user accepts the disclaimer; EFalse if doesn't.
+
         * @return ETrue if the user accepts the disclaimer; EFalse if not.
 
         */
 
         */
 
         TBool ShowDisclaimerL(RFs& aFs, const TDesC& aFilename);
 
         TBool ShowDisclaimerL(RFs& aFs, const TDesC& aFilename);
Line 243: Line 249:
 
==See also==
 
==See also==
  
* [[Showing a manufacturer disclaimer during application installation]]
+
* [[Archived:Showing a manufacturer disclaimer during application installation on Symbian]]
* [http://developer.symbian.com/wiki/display/pub/Symbian+Signed+Test+Criteria Symbian Signed Test Criteria] (especially the test case CAP-03)
+
* [[Symbian Signed Test Criteria]] (especially the test case CAP-03)
 
* [[How to conform with Symbian Signed criteria]]
 
* [[How to conform with Symbian Signed criteria]]
 
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Files/Data]]
 

Latest revision as of 14:29, 22 August 2012

Article Metadata
Tested with
Devices(s): Nokia N95 8GB
CompatibilityArticle
Keywords: RFs, RFile, BaflUtils, CAknMessageQueryDialog, RFs::Connect(), RFile::Open(), RFile::Size(), RFile::Read(), RFile::Close(), BaflUtils::FileExists(), BaflUtils::DeleteFile(), CAknMessageQueryDialog::RunLD()
Created: tapla (25 Apr 2008)
Last edited: lpvalente (22 Aug 2012)

Contents

[edit] Overview

This code snippet demonstrates how to display a manufacturer disclaimer when an application is launched for the first time. This behavior is required at least for VoIP applications that are meant to be sent to Symbian for signing.

In practice, the requested behavior is implemented by deleting the disclaimer file after it has been accepted for the first time. Every time the application is run, it is checked whether or not the file exists.

This snippet can be self-signed.

[edit] data\disclaimer.txt

Here is an example of the disclaimer text by Symbian for VoIP applications:

You are about to use <APPLICATION NAME>, which is
developed and owned by <YOUR COMPANY NAME>. The
manufacturer of this device shall have no liability for
any aspect of the application whatsoever, including its
performance, call routing, intellectual property rights
or support.

[edit] PKG file

Install the disclaimer file to the device by adding the following line to the PKG file:

"..\data\disclaimer.txt" - "!:\private\E9D7CF12\disclaimer.txt"

[edit] MMP file

The following libraries are required:

LIBRARY bafl.lib

[edit] RSS file

RESOURCE DIALOG r_disclaimer_dialog
{
flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
items=
{
DLG_LINE
{
type = EAknCtPopupHeadingPane;
id = EAknMessageQueryHeaderId;
itemflags = EEikDlgItemNonFocusing;
control = AVKON_HEADING
{
headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
};
},
DLG_LINE
{
type = EAknCtMessageQuery;
id = EAknMessageQueryContentId;
control = AVKON_MESSAGE_QUERY
{
};
}
};
}

[edit] Header file

    public:  // Constructors and destructor
/**
* 2nd phase constructor.
*/

void ConstructL();
 
private: // New methods
/**
* Shows the disclaimer dialog.
* @return ETrue if the user accepts the disclaimer; EFalse if not.
*/

TBool ShowDisclaimerL(RFs& aFs, const TDesC& aFilename);
 
/**
* Deletes the disclaimer file.
*/

void DeleteDisclaimerL(RFs& aFs, const TDesC& aFilename);

[edit] Source file

#include <aknmessagequerydialog.h>  // CAknMessageQueryDialog
#include <BAUTILS.H> // BaflUtils
#include <EIKENV.H> // CEikonEnv
void CMyAppUi::ConstructL()
{
// Initialize the UI. This has to be done before the disclaimer dialog is
// shown.
BaseConstructL(CAknAppUi::EAknEnableSkin);
 
// Connect to the file server session
RFs fsSession;
User::LeaveIfError(fsSession.Connect());
CleanupClosePushL(fsSession);
 
// The disclaimer file
_LIT(KFilename, "C:\\private\\E9D7CF12\\disclaimer.txt");
 
// If the disclaimer file exists, the application hasn't been run yet
if (BaflUtils::FileExists(fsSession, KFilename))
{
// Show the disclaimer dialog
TBool selectedOption;
TRAPD(showErr, selectedOption = ShowDisclaimerL(fsSession, KFilename));
if (showErr != KErrNone)
{
// TODO: Error handling
}
if (!selectedOption)
{
// The user canceled the disclaimer dialog. Exit the application.
CleanupStack::PopAndDestroy(); // fsSession
Exit();
}
else
{
// The user continued with the application launch.
// Delete the disclaimer file so that it won't be around the next time the
// application is run.
TRAPD(deleteErr, DeleteDisclaimerL(fsSession, KFilename));
if (deleteErr != KErrNone)
{
// TODO: Error handling
}
}
}
 
CleanupStack::PopAndDestroy(); // fsSession
 
// ...
}
TBool CMyAppUi::ShowDisclaimerL(RFs& aFs, const TDesC& aFilename)
{
// Open the disclaimer text file
RFile file;
TInt openError = file.Open(aFs, aFilename, EFileRead);
if (openError != KErrNone)
{
_LIT(KErrMsg, "Cannot open the disclaimer file for reading.");
_LIT(KExitingApp, "Exiting app.");
CEikonEnv::Static()->InfoWinL(KErrMsg, KExitingApp);
User::Leave(openError);
}
CleanupClosePushL(file);
 
// Read file size
TInt fileSize = 0;
TInt sizeError = file.Size(fileSize);
if (sizeError != KErrNone)
{
CleanupStack::PopAndDestroy(); // file
User::Leave(sizeError);
}
 
// Read file contents
HBufC8* disclaimerText8 = HBufC8::NewLC(fileSize);
TPtr8 disclaimerPtr = disclaimerText8->Des();
TInt ioError = file.Read(disclaimerPtr, fileSize);
if (ioError != KErrNone)
{
CleanupStack::PopAndDestroy(2); // disclaimerText8, file
User::Leave(ioError);
}
 
// Done with the file. Close it.
file.Close();
 
// Convert the 8-bit disclaimer text to 16-bit
HBufC* disclaimerText = HBufC::NewLC(disclaimerText8->Length());
disclaimerText->Des().Copy(*disclaimerText8);
 
// Show the disclaimer dialog
_LIT(KTitle, "MyApplication");
CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*disclaimerText);
CleanupStack::PushL(dlg);
dlg->PrepareLC(R_DISCLAIMER_DIALOG);
dlg->SetHeaderTextL(KTitle);
CleanupStack::Pop(dlg);
 
TBool result = dlg->RunLD();
 
CleanupStack::PopAndDestroy(3); // disclaimerText, disclaimerText8, file
 
return result;
}
void CMyAppUi::DeleteDisclaimerL(RFs& aFs, const TDesC& aFilename)
{
// Delete the disclaimer file
TInt deleteError = BaflUtils::DeleteFile(aFs, aFilename);
if (deleteError != KErrNone)
{
User::Leave(deleteError);
}
}

[edit] Postconditions

A manufacturer disclaimer is displayed when the application is launched for the first time. The user is given the option to continue with the launch or abort it. If the user decides to accept the disclaimer, the disclaimer file is deleted from the device.

[edit] See also

This page was last modified on 22 August 2012, at 14:29.
115 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×