634 } |
634 } |
635 |
635 |
636 |
636 |
637 /** |
637 /** |
638 Function to retrieve the active primary and secondary filters |
638 Function to retrieve the active primary and secondary filters |
639 This should leave with KErrNotFound if cannot find one or any system wide error codes |
639 This should return KErrNotFound if cannot find one or return any of the system wide error codes |
640 */ |
640 */ |
641 TInt CULoggerServer::GetActiveFilters(RArray<TUint32>& aListBuffer,TInt aFilterType) |
641 TInt CULoggerServer::GetActiveFilters(RArray<TUint32>& aListBuffer,TInt aFilterType) |
642 { |
642 { |
643 TInt ret = KErrNotFound; |
643 TInt ret = KErrNotFound; |
644 RArray<TPtrC8> aValues; |
644 RArray<TPtrC8> aValues; |
645 if(aFilterType == 1) |
645 if(aFilterType == 1) |
646 { |
646 { |
647 ret = GetValuesL(KPrimaryFilterSection,aValues); |
647 TRAPD(err, ret = GetValuesL(KPrimaryFilterSection,aValues)); |
|
648 if (err != KErrNone) |
|
649 { |
|
650 return err; |
|
651 } |
|
652 |
648 if(ret==KErrNone) |
653 if(ret==KErrNone) |
649 { |
654 { |
650 TInt i =0; |
655 TInt i =0; |
651 TPtrC8 val; |
656 TPtrC8 val; |
652 TUint8 int_val; |
657 TUint8 int_val; |
653 while(i<aValues.Count()) |
658 while(i<aValues.Count()) |
654 { |
659 { |
655 TLex8 lex_val(aValues[++i]); |
660 TLex8 lex_val(aValues[++i]); |
656 ret = lex_val.Val(int_val,EDecimal); |
661 ret = lex_val.Val(int_val,EDecimal); |
657 if(ret==KErrNone) |
662 if(ret == KErrNone) |
658 aListBuffer.Append(int_val); |
663 { |
|
664 ret = aListBuffer.Append(int_val); |
|
665 if (ret != KErrNone) |
|
666 { |
|
667 return ret; |
|
668 } |
|
669 } |
659 else |
670 else |
|
671 { |
660 return KErrCorrupt; |
672 return KErrCorrupt; |
|
673 } |
661 i++; |
674 i++; |
662 } |
675 } |
663 } |
676 } |
664 } |
677 } |
665 else if(aFilterType == 2) |
678 else if(aFilterType == 2) |
666 { |
679 { |
667 ret = GetValuesL(KSecondaryFilterSection,aValues); |
680 TRAPD(err, ret = GetValuesL(KSecondaryFilterSection,aValues)); |
|
681 if (err != KErrNone) |
|
682 { |
|
683 return err; |
|
684 } |
668 if(ret==KErrNone) |
685 if(ret==KErrNone) |
669 { |
686 { |
670 TInt i =0; |
687 TInt i =0; |
671 TPtrC8 val; |
688 TPtrC8 val; |
672 TUint int_val; |
689 TUint int_val; |
673 while(i<aValues.Count()) |
690 while(i<aValues.Count()) |
674 { |
691 { |
675 TLex8 lex_val(aValues[++i]); |
692 TLex8 lex_val(aValues[++i]); |
676 ret = lex_val.Val(int_val,EDecimal); |
693 ret = lex_val.Val(int_val,EDecimal); |
677 if(ret==KErrNone) |
694 if(ret == KErrNone) |
678 aListBuffer.Append(int_val); |
695 { |
|
696 ret = aListBuffer.Append(int_val); |
|
697 if (ret != KErrNone) |
|
698 { |
|
699 return ret; |
|
700 } |
|
701 } |
679 else |
702 else |
|
703 { |
680 return KErrCorrupt; |
704 return KErrCorrupt; |
|
705 } |
681 i++; |
706 i++; |
682 } |
707 } |
683 } |
708 } |
684 else |
709 else |
685 { |
710 { |
686 if(ret==KErrNotFound)//i.e. if there are no values in the array --> change to if(filters.Count = 0)? |
711 if(ret==KErrNotFound)//i.e. if there are no values in the array --> change to if(filters.Count = 0)? |
|
712 { |
687 ret=KErrNone; |
713 ret=KErrNone; |
|
714 } |
688 } |
715 } |
689 } |
716 } |
690 return ret; |
717 return ret; |
691 } |
718 } |
692 |
719 |
1146 } |
1173 } |
1147 } |
1174 } |
1148 } |
1175 } |
1149 |
1176 |
1150 |
1177 |
|
1178 /* |
|
1179 * Cleanup RPointerArray<TPluginConfiguration>* object by calling ResetAndDestroy to delete memory |
|
1180 * allocated as TPluginConfigurations whose ownership has been passed to the RPointerArray. |
|
1181 * |
|
1182 */ |
|
1183 void CULoggerServer::CleanupTPluginConfigArray(TAny* aPtr) |
|
1184 { |
|
1185 RPointerArray<TPluginConfiguration>* ptrArray = reinterpret_cast<RPointerArray<TPluginConfiguration>*>(aPtr); |
|
1186 ptrArray->ResetAndDestroy(); |
|
1187 ptrArray->Close(); |
|
1188 } |
|
1189 |
|
1190 |
1151 void CULoggerServer::InitializeFrameworksL() |
1191 void CULoggerServer::InitializeFrameworksL() |
1152 { |
1192 { |
1153 //<create plugin allocator (plugins)> |
1193 //<create plugin allocator (plugins)> |
1154 //output settings |
1194 //output settings |
1155 RBuf8 outPluginName; |
1195 RBuf8 outPluginName; |
1156 outPluginName.Create(KMaxPluginName); |
1196 outPluginName.CreateL(KMaxPluginName); |
|
1197 CleanupClosePushL(outPluginName); |
1157 RPointerArray<TPluginConfiguration> outputPluginSettings; |
1198 RPointerArray<TPluginConfiguration> outputPluginSettings; |
|
1199 CleanupStack::PushL(TCleanupItem(CleanupTPluginConfigArray, &outputPluginSettings)); |
1158 GetPluginAndSettingsL(outPluginName, &outputPluginSettings, EOutputPluginFilter); |
1200 GetPluginAndSettingsL(outPluginName, &outputPluginSettings, EOutputPluginFilter); |
1159 |
1201 |
1160 //control settings |
1202 //control settings |
1161 RBuf8 inputPluginName; |
1203 RBuf8 inputPluginName; |
1162 inputPluginName.Create(KMaxPluginName); |
1204 inputPluginName.CreateL(KMaxPluginName); |
|
1205 CleanupClosePushL(inputPluginName); |
1163 RPointerArray<TPluginConfiguration> inputPluginSettings; |
1206 RPointerArray<TPluginConfiguration> inputPluginSettings; |
1164 this->GetPluginAndSettingsL(inputPluginName, &inputPluginSettings, EInputPluginFilter); |
1207 CleanupStack::PushL(TCleanupItem(CleanupTPluginConfigArray, &inputPluginSettings)); |
|
1208 GetPluginAndSettingsL(inputPluginName, &inputPluginSettings, EInputPluginFilter); |
1165 |
1209 |
1166 #if defined(__LIGHTLOGGER_ENABLED) && defined(__VERBOSE_MODE) |
1210 #if defined(__LIGHTLOGGER_ENABLED) && defined(__VERBOSE_MODE) |
1167 __LOG("before creating CPluginAllocator") |
1211 __LOG("before creating CPluginAllocator") |
1168 #endif |
1212 #endif |
1169 |
1213 |
1170 //create plugin allocator (plugins) |
1214 //create plugin allocator (plugins) |
1171 if(!iPluginAllocator) |
1215 if(!iPluginAllocator) |
|
1216 { |
1172 iPluginAllocator = CPluginAllocator::NewL(outPluginName, inputPluginName); |
1217 iPluginAllocator = CPluginAllocator::NewL(outPluginName, inputPluginName); |
|
1218 } |
1173 |
1219 |
1174 #if defined(__LIGHTLOGGER_ENABLED) && defined(__VERBOSE_MODE) |
1220 #if defined(__LIGHTLOGGER_ENABLED) && defined(__VERBOSE_MODE) |
1175 __LOG("before creating COutputFramework") |
1221 __LOG("before creating COutputFramework") |
1176 #endif |
1222 #endif |
1177 //Initialize output framework |
1223 //Initialize output framework |
1178 if(!iOutputFramework) |
1224 if(!iOutputFramework) |
|
1225 { |
1179 iOutputFramework = COutputFramework::NewL(*(iPluginAllocator->GetOutputPlugin()), outputPluginSettings); |
1226 iOutputFramework = COutputFramework::NewL(*(iPluginAllocator->GetOutputPlugin()), outputPluginSettings); |
|
1227 } |
1180 |
1228 |
1181 //Initialize Control Framework |
1229 //Initialize Control Framework |
1182 if(!iInputFramework) |
1230 if(!iInputFramework) |
|
1231 { |
1183 iInputFramework = CInputFramework::NewL(iPluginAllocator->GetInputPlugin(), inputPluginSettings, this); |
1232 iInputFramework = CInputFramework::NewL(iPluginAllocator->GetInputPlugin(), inputPluginSettings, this); |
|
1233 } |
1184 |
1234 |
1185 //cleanup |
1235 //cleanup |
1186 outPluginName.Close(); |
1236 CleanupStack::PopAndDestroy(4, &outPluginName); // and outputPluginSettings, inputPluginName and inputPluginSettings |
1187 outputPluginSettings.ResetAndDestroy(); |
|
1188 outputPluginSettings.Close(); |
|
1189 inputPluginName.Close(); |
|
1190 inputPluginSettings.ResetAndDestroy(); |
|
1191 inputPluginSettings.Close(); |
|
1192 |
1237 |
1193 iDataWatcher = CULoggerWatcher::NewL(); |
1238 iDataWatcher = CULoggerWatcher::NewL(); |
1194 } |
1239 } |
1195 |
1240 |
1196 |
1241 |
1197 void CULoggerServer::PrepareControlDataPayloadL(RBuf8& aPayloadBuf, const RArray<TPtrC8>& aArray) |
1242 void CULoggerServer::PrepareControlDataPayloadL(RBuf8& aPayloadBuf, const RArray<TPtrC8>& aArray) |
1198 { |
1243 { |
1199 aPayloadBuf.Create(aArray.Count()*32); |
1244 aPayloadBuf.CreateL(aArray.Count()*32); |
1200 for(TInt i=0; i<aArray.Count(); i++) |
1245 for(TInt i=0; i<aArray.Count(); i++) |
1201 { |
1246 { |
1202 if(aPayloadBuf.MaxSize() < aPayloadBuf.Length()+aArray[i].Length()) |
1247 if(aPayloadBuf.MaxSize() < aPayloadBuf.Length()+aArray[i].Length()) |
|
1248 { |
1203 aPayloadBuf.ReAllocL(aPayloadBuf.Length()+(aArray[i].Length()*10)); |
1249 aPayloadBuf.ReAllocL(aPayloadBuf.Length()+(aArray[i].Length()*10)); |
|
1250 } |
1204 aPayloadBuf.Append(aArray[i]); |
1251 aPayloadBuf.Append(aArray[i]); |
1205 if(i < aArray.Count()-1) //skip last sparator as it will be added automatically |
1252 if(i < aArray.Count()-1) //skip last sparator as it will be added automatically |
|
1253 { |
1206 aPayloadBuf.Append(DATA_SEPARATOR); |
1254 aPayloadBuf.Append(DATA_SEPARATOR); |
|
1255 } |
1207 } |
1256 } |
1208 } |
1257 } |
1209 |
1258 |
1210 |
1259 |
1211 void CULoggerServer::PrepareControlDataPayloadL(RBuf8& aPayloadBuf, const RArray<TUint32>& aArray) |
1260 void CULoggerServer::PrepareControlDataPayloadL(RBuf8& aPayloadBuf, const RArray<TUint32>& aArray) |
1212 { |
1261 { |
1213 aPayloadBuf.Create(aArray.Count()*4); |
1262 aPayloadBuf.CreateL(aArray.Count()*4); |
1214 for(TInt i=0; i<aArray.Count(); i++) |
1263 for(TInt i=0; i<aArray.Count(); i++) |
1215 { |
1264 { |
1216 TBuf8<64> b; |
1265 TBuf8<64> b; |
1217 b.Num(aArray[i]); |
1266 b.Num(aArray[i]); |
1218 if(aPayloadBuf.MaxSize() < aPayloadBuf.Length()+b.Length()) |
1267 if(aPayloadBuf.MaxSize() < aPayloadBuf.Length()+b.Length()) |
|
1268 { |
1219 aPayloadBuf.ReAllocL(aPayloadBuf.Length()+(b.Length()*10)); |
1269 aPayloadBuf.ReAllocL(aPayloadBuf.Length()+(b.Length()*10)); |
|
1270 } |
1220 aPayloadBuf.Append(b); |
1271 aPayloadBuf.Append(b); |
1221 if(i < aArray.Count()-1) //skip last sparator as it will be added automatically |
1272 if(i < aArray.Count()-1) //skip last sparator as it will be added automatically |
|
1273 { |
1222 aPayloadBuf.Append(DATA_SEPARATOR); |
1274 aPayloadBuf.Append(DATA_SEPARATOR); |
|
1275 } |
1223 } |
1276 } |
1224 } |
1277 } |
1225 |
1278 |
1226 |
1279 |
1227 TInt CULoggerServer::RestartOutputting() |
1280 TInt CULoggerServer::RestartOutputting() |