21 |
21 |
22 #include <e32def.h> // For TUint16 |
22 #include <e32def.h> // For TUint16 |
23 #include <e32cmn.h> // For TDesC8 |
23 #include <e32cmn.h> // For TDesC8 |
24 #include <klib.h> // For DBase |
24 #include <klib.h> // For DBase |
25 |
25 |
26 NONSHARABLE_CLASS ( TNameTable ) |
26 NONSHARABLE_CLASS( TNameTableEntry ) |
27 { |
27 { |
28 public: |
28 public: |
29 TNameTable( const TUint32 aName, const TUint16 aPhonetAddress, const TUint8 aFlags ) |
|
30 :iName(aName), |
|
31 iPhonetAddress(aPhonetAddress), |
|
32 iFlags(aFlags) |
|
33 {} |
|
34 |
29 |
35 TUint32 iName; |
30 TNameTableEntry( const TUint32 aName, const TUint16 aPhonetAddress, const TUint8 aFlags ) |
36 TUint16 iPhonetAddress; |
31 :iName(aName), |
37 TUint8 iFlags; |
32 iPhonetAddress(aPhonetAddress), |
38 }; |
33 iFlags(aFlags) |
|
34 {} |
39 |
35 |
40 NONSHARABLE_CLASS (DNameRecords) : public DBase |
36 TUint32 iName; |
41 { |
37 TUint16 iPhonetAddress; |
42 public: |
38 TUint8 iFlags; |
43 DNameRecords(); |
|
44 ~DNameRecords(); |
|
45 |
39 |
46 RArray<TNameTable*> iNameTableArray; |
40 }; |
47 |
41 |
|
42 NONSHARABLE_CLASS( DNameRecords ) : public DBase |
|
43 { |
48 |
44 |
49 TUint8 AddName( const TUint32 aName, |
45 public: |
50 const TUint16 aPhonetAddress, |
|
51 const TUint8 aFlags ); |
|
52 |
46 |
53 TUint8 RemoveName( const TUint32 aName ); |
47 /* |
|
48 * Assumption each function executed from single thread at the time. |
|
49 * Constructor |
|
50 */ |
|
51 DNameRecords(); |
54 |
52 |
55 TInt32 LookupPhonetAddress( const TUint32 aName, TUint16* aPhonetAddress ); |
53 /* |
|
54 * Assumption each function executed from single thread at the time. |
|
55 * Destructor |
|
56 */ |
|
57 ~DNameRecords(); |
56 |
58 |
57 RArray <TNameTable*>* GetNameTable(); |
59 /* |
|
60 * Assumption each function executed from single thread at the time. |
|
61 * @param aName, name to be added |
|
62 * @param aPhonetAddress, PhoNet address of the name to be added |
|
63 * @param aFlags, flags of the name to be added |
|
64 * @return PN_NAME_UNKNOWN if flags value invalid, PN_NAME_NOT_ALLOWED if not changeable name |
|
65 */ |
|
66 TUint8 AddName( const TUint32 aName, |
|
67 const TUint16 aPhonetAddress, |
|
68 const TUint8 aFlags ); |
58 |
69 |
59 TInt32 NameQuery( const TUint32 aName, const TUint32 aMask, RArray <TNameTable*> *aResultsArray ); |
70 /* |
60 }; |
71 * Assumption each function executed from single thread at the time. |
|
72 * @param aName |
|
73 * @param aPhonetAddress, modified to contain names PhoNet address if name is found |
|
74 * @return KErrNone if found KErrNotFound if not |
|
75 */ |
|
76 TInt LookupPhonetAddress( const TUint32 aName, TUint16* aPhonetAddress ); |
|
77 |
|
78 /* |
|
79 * Assumption each function executed from single thread at the time. |
|
80 * @param aName |
|
81 * @param aPhonetAddress, modified to contain names PhoNet address if name is found |
|
82 * @param aFlags, modified to contain names flag if name is found |
|
83 * @return KErrNone if found KErrNotFound if not |
|
84 */ |
|
85 TInt LookupNamePhonetAddressAndFlags( const TUint32 aName, TUint16* aPhonetAddress, TUint8* aFlags ); |
|
86 |
|
87 /* |
|
88 * Assumption each function executed from single thread at the time. |
|
89 * @param aName |
|
90 * @param aMask, mask for matching names |
|
91 * @param aResultsArray, array where matches are appended |
|
92 */ |
|
93 void NameQuery( const TUint32 aName, const TUint32 aMask, RArray <TNameTableEntry*> *aResultsArray ); |
|
94 |
|
95 /* |
|
96 * Assumption each function executed from single thread at the time. |
|
97 * @param aName |
|
98 * @return PN_NAME_UNKNOWN if name not found, PN_NAME_NOT_ALLOWED if not allowed to remove name |
|
99 */ |
|
100 TUint8 RemoveName( const TUint32 aName ); |
|
101 |
|
102 private: |
|
103 |
|
104 /* |
|
105 * Adds new name to name table. |
|
106 * @param aName |
|
107 * @param aPhonetAddress |
|
108 * @param aFlags |
|
109 * @return PN_NAME_NOT_ALLOWED if name not found or it's address was equal to own device router, otherwise PN_NAME_OK |
|
110 */ |
|
111 TUint8 AddNewName( const TUint32 aName, |
|
112 const TUint16 aPhonetAddress, |
|
113 const TUint8 aFlags ); |
|
114 |
|
115 /* |
|
116 * Ownership of the parameter not given. |
|
117 * Adds existing name to the name table. |
|
118 * @param aNameTableEntry |
|
119 * @param aName |
|
120 * @param aPhonetAddress |
|
121 * @param aFlags |
|
122 * @return PN_NAME_NOT_ALLOWED if not changeable PN_NAME_OK otherwise |
|
123 */ |
|
124 TUint8 AddExistinNameToNameTableArray( TNameTableEntry* aNameTableEntry, |
|
125 const TUint32 aName, |
|
126 const TUint16 aPhonetAddress, |
|
127 const TUint8 aFlags ); |
|
128 |
|
129 /* |
|
130 * Adds and creates new name table entry |
|
131 * @param aName |
|
132 * @param aPhonetAddress |
|
133 * @param aFlags |
|
134 * @return PN_NAME_NOT_ALLOWED if router object tried to add PN_NAME_OK otherwise |
|
135 */ |
|
136 TUint8 AddNewNameToNameTableArray( const TUint32 aName, |
|
137 const TUint16 aPhonetAddress, |
|
138 const TUint8 aFlags ); |
|
139 |
|
140 /* |
|
141 * Ownership of the return value not given. |
|
142 * @param aName |
|
143 * @return pointer to table entry, NULL if not found |
|
144 */ |
|
145 TNameTableEntry* FindMatchingNameTableEntry( const TUint32 aName ); |
|
146 |
|
147 /* |
|
148 * Ownership of the array is not given. |
|
149 * @param aName |
|
150 * @param aMask, mask to find name table entries |
|
151 * @aResultsArray, array where found name table entries are added |
|
152 */ |
|
153 void FindMatchingNameTableEntriesWithMask( const TUint32 aName, |
|
154 const TUint32 aMask, |
|
155 RArray <TNameTableEntry*>* aResultsArray ); |
|
156 |
|
157 /* |
|
158 * Remove entry given as paramater. |
|
159 * @param aNameEntryToRemove |
|
160 */ |
|
161 void RemoveUndefinedEntry( TNameTableEntry& aNameEntryToRemove ); |
|
162 |
|
163 // Name table array, owned. |
|
164 RArray<TNameTableEntry*> iNameTableArray; |
|
165 |
|
166 }; |
61 |
167 |
62 #endif /* __NAMERECORDS_H__ */ |
168 #endif /* __NAMERECORDS_H__ */ |