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