00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00038 #include "secureclientandserver.h"
00039 #include "secureclient.h"
00040
00041 LOCAL_D CConsoleBase* console;
00042
00043 void DoExampleL()
00044 {
00045 console->Printf(KTxtTestingCountServer);
00046
00047
00048 RSecureSession countserv;
00049 User::LeaveIfError(countserv.Connect());
00050
00051
00052 RSecureSubSession counterA;
00053 counterA.Open(countserv);
00054
00055
00056 console->Printf(KTxtInitCounterAWith);
00057 console->Printf(KTxtOption);
00058 TUint8 inpOption = console->Getch();
00059 if(inpOption == '1')
00060 {
00061
00062 counterA.SetCounterFromFileL();
00063 console->Printf(KTxtInitFromFile,counterA.CounterValueL());
00064 }
00065 else
00066 {
00067
00068 _LIT(KTxtValueString,"a2");
00069 console->Printf(KTxtValueString);
00070
00071 TInt err = counterA.SetFromString(KTxtValueString);
00072 if (err == ENonNumericString)
00073 {
00074
00075 console->Printf(KTxtInitCounterFailed);
00076 }
00077 else
00078 {
00079
00080 console->Printf(KTxtInitCounterSucceeded);
00081 }
00082 }
00083 RSecureSubSession counterB;
00084
00085
00086 counterB.Open(countserv);
00087
00088
00089 console->Printf(KTxtInitCounterBWith);
00090 console->Printf(KTxtOption);
00091 inpOption = console->Getch();
00092 if(inpOption == '1')
00093 {
00094
00095 counterB.SetCounterFromFileL();
00096 console->Printf(KTxtInitFromFile,counterB.CounterValueL());
00097 }
00098 else
00099 {
00100
00101 _LIT(KTxtLegalString,"100");
00102 console->Printf(KTxtLegalString);
00103
00104 TInt err = counterB.SetFromString(KTxtLegalString);
00105 if (err == ENonNumericString)
00106 {
00107
00108 console->Printf(KTxtInitCounterFailed);
00109 }
00110 else
00111 {
00112
00113
00114 console->Printf(KTxtInitCounterSucceeded);
00115 }
00116 }
00117
00118
00119 console->Printf(KMsgPressAnyKey);
00120 console->Getch();
00121 console->ClearScreen();
00122
00123
00124 console->Printf(KTxtGetCounterAValue,counterA.CounterValueL());
00125 console->Printf(KTxtGetCounterBValue,counterB.CounterValueL());
00126
00127
00128 console->Printf(KMsgPressAnyKey);
00129 console->Getch();
00130 console->ClearScreen();
00131
00132
00133 _LIT(KTxt1,"\nIncrease counterA by default value (i.e. 1)..\n");
00134 console->Printf(KTxt1);
00135 counterA.Increase();
00136 console->Printf(KTxtGetCounterAValue,counterA.CounterValueL());
00137
00138
00139 _LIT(KTxt2,"\nIncrease counterA by 2..\n");
00140 console->Printf(KTxt2);
00141
00142
00143 counterA.IncreaseByL(2);
00144 console->Printf(KTxtGetCounterAValue,counterA.CounterValueL());
00145
00146
00147 _LIT(KTxt3,"\nIncrease counterB by default value (i.e. 1)..\n");
00148 console->Printf(KTxt3);
00149 counterB.Increase();
00150 console->Printf(KTxtGetCounterBValue,counterB.CounterValueL());
00151
00152
00153 _LIT(KTxt4,"\nIncrease counterA by 17..\n");
00154 console->Printf(KTxt4);
00155
00156 counterA.IncreaseByL(17);
00157 console->Printf(KTxtGetCounterAValue,counterA.CounterValueL());
00158
00159
00160 console->Printf(KMsgPressAnyKey);
00161 console->Getch();
00162 console->ClearScreen();
00163
00164
00165 _LIT(KTxt5,"\nIncrease counterB by 5..\n");
00166 console->Printf(KTxt5);
00167 counterB.IncreaseByL(5);
00168 console->Printf(KTxtGetCounterBValue,counterB.CounterValueL());
00169
00170
00171 _LIT(KTxt6,"\nDecrease counterA..\n");
00172 console->Printf(KTxt6);
00173 counterA.Decrease();
00174 console->Printf(KTxtGetCounterAValue,counterA.CounterValueL());
00175
00176
00177 _LIT(KTxt7,"\nDecrease counterB by 3..\n");
00178 console->Printf(KTxt7);
00179 console->Printf(KTxtGetCounterBValue,counterB.CounterValueL());
00180
00181
00182 counterB.DecreaseByL(3);
00183
00184
00185 _LIT(KTxt8,"\nResource count is.. %d \n");
00186 console->Printf(KTxt8,countserv.ResourceCountL());
00187
00188
00189 console->Printf(KTxtSaveToFile);
00190 TUint8 sel = console->Getch();
00191 if(sel == 'a')
00192 {
00193
00194 console->Printf(KTxtSelectCounter,sel);
00195 console->Printf(KTxtSaveCounter);
00196
00197 counterA.SaveCounterL();
00198 }
00199 else if(sel == 'b')
00200 {
00201
00202 console->Printf(KTxtSelectCounter,sel);
00203 console->Printf(KTxtSaveCounter);
00204
00205 counterB.SaveCounterL();
00206 }
00207
00208
00209 _LIT(KTxt9,"\nClosing counterA and then CounterB..\n");
00210 console->Printf(KTxt9);
00211 counterA.Close();
00212 counterB.Close();
00213 countserv.Close();
00214 }
00215
00216 GLDEF_C TInt E32Main()
00217 {
00218 __UHEAP_MARK;
00219 CTrapCleanup* cleanup = CTrapCleanup::New();
00220
00221 TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
00222 if (createError)
00223 return createError;
00224
00225 TRAPD(mainError, DoExampleL());
00226 if (mainError)
00227 console->Printf(KTextFailed, mainError);
00228 console->Printf(KTextPressAnyKey);
00229 console->Getch();
00230
00231 delete console;
00232 delete cleanup;
00233 __UHEAP_MARKEND;
00234 return KErrNone;
00235 }