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
00036 #include "publish.h"
00037
00038 LOCAL_D CConsoleBase* console;
00039
00045 void PublishL(RProperty& aProperty,TDes16& aBuf)
00046 {
00047 console->Printf(KTxtPublish);
00048
00049
00050
00051 User::LeaveIfError(aProperty.Set(aBuf));
00052 console->Printf(KTxtArray);
00053
00054
00055 TInt bufLength = aBuf.Length();
00056 for(TInt ix = 0; ix < bufLength; ix++)
00057 {
00058 console->Printf(KTxtArrayElement,aBuf[ix]);
00059 }
00060 console->Printf(KTxtNewLine);
00061 }
00062
00063 void DoExampleL()
00064 {
00065 console->Printf(KTxtStPublish);
00066 console->Printf(KTxtDefine);
00067
00068
00069 RProperty::Define(KMyPropertyCat, KMyPropertyName,RProperty::EByteArray,KAllowAllPolicy,KAllowAllPolicy,KArraySize);
00070 RProperty myProperty;
00071
00072 User::LeaveIfError(myProperty.Attach(KMyPropertyCat,KMyPropertyName,EOwnerThread));
00073 console->Printf(KTxtCreateHandle);
00074
00075
00076 TUint16 array[KArraySize] = {10,20,30,40};
00077
00078
00079 TBuf16<KBufSize> buf;
00080
00081
00082 buf.Copy(&array[0],sizeof(array));
00083 buf.SetLength(KArraySize);
00084
00085
00086 PublishL(myProperty,buf);
00087
00088
00089 array[0] = 0x00ab;
00090 array[1] = 0x00bc;
00091 array[2] = 0x00cd;
00092 array[3] = 0x00de;
00093 array[4] = 0x00ef;
00094 array[5] = 0x00fa;
00095
00096 buf.Copy(&array[0],sizeof(array));
00097
00098 buf.SetLength(KArraySize);
00099
00100
00101 console->Printf(KTxtEnter);
00102 while(console->Getch()!= EKeyEnter)
00103 {
00104 console->Printf(KTxtEnter);
00105 }
00106
00107
00108 PublishL(myProperty,buf);
00109
00110
00111
00112 buf.Copy(KStop);
00113 console->Printf(KTxtEnter);
00114
00115
00116 while(console->Getch()!= EKeyEnter)
00117 {
00118 console->Printf(KTxtEnter);
00119 }
00120
00121
00122 PublishL(myProperty,buf);
00123
00124
00125
00126 myProperty.Close();
00127
00128
00129 while(console->Getch()!= EKeyEnter)
00130 {
00131 console->Printf(KTxtEnter);
00132 }
00133
00134
00135 User::LeaveIfError(RProperty::Delete(KMyPropertyCat, KMyPropertyName));
00136 }
00137
00138 GLDEF_C TInt E32Main()
00139 {
00140 __UHEAP_MARK;
00141 CTrapCleanup* cleanup = CTrapCleanup::New();
00142
00143 TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
00144 if (createError)
00145 return createError;
00146
00147 TRAPD(mainError, DoExampleL());
00148 if (mainError)
00149 console->Printf(KTextFailed, mainError);
00150 console->Printf(KTextPressAnyKey);
00151 console->Getch();
00152
00153 delete console;
00154 delete cleanup;
00155 __UHEAP_MARKEND;
00156 return KErrNone;
00157 }