diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/secureserverccountsubsession_8cpp-source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/secureserverccountsubsession_8cpp-source.html Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,162 @@ + + +TB10.1 Example Applications: examples/Base/IPC/secureserver/secureserverccountsubsession.cpp Source File + + + + +

examples/Base/IPC/secureserver/secureserverccountsubsession.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+00002 // All rights reserved.
+00003 // This component and the accompanying materials are made available
+00004 // under the terms of "Eclipse Public License v1.0"
+00005 // which accompanies this distribution, and is available
+00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
+00007 //
+00008 // Initial Contributors:
+00009 // Nokia Corporation - initial contribution.
+00010 //
+00011 // Contributors:
+00012 //
+00013 // Description:
+00014 // Contains the implementation of functions described in the CSecureServerSubSession class.
+00015 //
+00016 
+00017 
+00018 
+00022 #include "secureclientandserver.h"
+00023 #include "secureserver.h"
+00024 
+00030 CSecureServerSubSession::CSecureServerSubSession(CSecureServerSession* aSession) : iSession(aSession)
+00031  {
+00032  }
+00033 
+00038 void CSecureServerSubSession::SetFromStringL(const RMessage2& aMessage)
+00039         {
+00040         TInt deslen = aMessage.GetDesLength(0);
+00041         RBuf buffer;
+00042 
+00043         buffer.CreateL(deslen);
+00044         buffer.CleanupClosePushL();
+00045         // The descriptor is encapsulated in the 0th offset of aMessage.
+00046         // Hence, read the 0th offset of the message to the buffer.
+00047         aMessage.ReadL(0,buffer,0);
+00048         // Check for empty string.
+00049         if (buffer.Length() == 0)
+00050                 {
+00051                 User::Leave(ENonNumericString);
+00052                 }
+00053         TLex16 lexer;
+00054         lexer.Assign(buffer);
+00055         while (!lexer.Eos())
+00056                 {
+00057                 TChar thechar;
+00058                 thechar = lexer.Peek();
+00059                 // Check for non numeric character.
+00060                 if (!thechar.IsDigit())
+00061                         {
+00062                         User::Leave(ENonNumericString);
+00063                         }
+00064                 lexer.Inc();
+00065                 }
+00066         lexer.Assign(buffer);
+00067         if (lexer.Val(iCount))
+00068                 {
+00069                 User::Leave(ENonNumericString);
+00070                 }
+00071         CleanupStack::PopAndDestroy();
+00072         }
+00073 
+00077 void CSecureServerSubSession::Increase()
+00078         {
+00079         iCount ++;
+00080         }
+00081 
+00087 void CSecureServerSubSession::IncreaseBy(const RMessage2& aMessage)
+00088         {
+00089         iCount += aMessage.Int0();
+00090         }
+00091 
+00095 void CSecureServerSubSession::Decrease()
+00096         {
+00097         iCount --;
+00098         }
+00099 
+00105 void CSecureServerSubSession::DecreaseBy(const RMessage2& aMessage)
+00106         {
+00107         iCount -= aMessage.Int0();
+00108         }
+00109 
+00114 void CSecureServerSubSession::Reset()
+00115         {
+00116         iCount = 0;
+00117         }
+00118 
+00123 void CSecureServerSubSession::CounterValueL(const RMessage2& aMessage)
+00124         {
+00125         // Write the value of counter to the 0th offset of aMessage by converting it to a package.
+00126         TPckgBuf<TInt> p(iCount);
+00127         aMessage.WriteL(0,p);
+00128         }
+00129 
+00142 void CSecureServerSubSession::SaveCounterValueL()
+00143         {
+00144         RFs fs;
+00145         User::LeaveIfError(fs.Connect());
+00146         _LIT(KFileName,"counter.dat");
+00147         User::LeaveIfError(fs.CreatePrivatePath(RFs::GetSystemDrive()));
+00148         User::LeaveIfError(fs.SetSessionToPrivate(RFs::GetSystemDrive()));
+00149         TFileName thePath;
+00150         User::LeaveIfError(fs.PrivatePath(thePath));
+00151         TInt err=fs.MkDir(thePath);
+00152         if (err!=KErrAlreadyExists)
+00153                 {
+00154                 User::LeaveIfError(err);
+00155                 }
+00156         thePath.Append(KFileName);
+00157         RFile file;
+00158 
+00159         TBuf8<20> counterVal;
+00160         counterVal.FillZ();
+00161         // Append the counter value to a buffer and write to the file.
+00162         counterVal.AppendNum(iCount);
+00163         User::LeaveIfError(file.Replace(fs,thePath,EFileWrite));
+00164         User::LeaveIfError(file.Write(counterVal));
+00165         User::LeaveIfError(file.Flush());
+00166 
+00167         file.Close();
+00168         fs.Close();
+00169         }
+00170 
+00175 void CSecureServerSubSession::SetCounterValueFromFileL()
+00176         {
+00177         RFs fs;
+00178         User::LeaveIfError(fs.Connect());
+00179         _LIT(KFileName,"counter.dat");
+00180         User::LeaveIfError(fs.CreatePrivatePath(RFs::GetSystemDrive()));
+00181         User::LeaveIfError(fs.SetSessionToPrivate(RFs::GetSystemDrive()));
+00182         TFileName thePath;
+00183         User::LeaveIfError(fs.PrivatePath(thePath));
+00184         TInt err=fs.MkDir(thePath);
+00185         if (err!=KErrAlreadyExists)
+00186                 {
+00187                 User::LeaveIfError(err);
+00188                 }
+00189         thePath.Append(KFileName);
+00190         RFile file;
+00191 
+00192         TBuf8<20> readVal;
+00193         User::LeaveIfError(file.Open(fs,thePath,EFileRead));
+00194         // Read counter value to the readVal buffer.
+00195         User::LeaveIfError(file.Read(readVal));
+00196         file.Close();
+00197         // Convert value in readVal to TInt.
+00198         TLex8 lex(readVal);
+00199         lex.Val(iCount);
+00200 
+00201         fs.Close();
+00202         }
+

Generated on Thu Jan 21 10:32:57 2010 for TB10.1 Example Applications by  + +doxygen 1.5.3
+ +