83 TUint32 id = aDestId; |
83 TUint32 id = aDestId; |
84 TUint32 tmpapId; |
84 TUint32 tmpapId; |
85 TCmDefConnType type; |
85 TCmDefConnType type; |
86 |
86 |
87 RCmManager * mgr = new(ELeave) RCmManager(); |
87 RCmManager * mgr = new(ELeave) RCmManager(); |
88 mgr->OpenL(); |
88 mgr->OpenLC(); |
89 |
89 |
90 if (aDefault) |
90 if (aDefault) |
91 { |
91 { |
92 TCmDefConnValue obj; |
92 TCmDefConnValue obj; |
93 mgr->ReadDefConnL(obj); |
93 mgr->ReadDefConnL(obj); |
94 id = obj.iId; |
94 id = obj.iId; |
95 type = obj.iType; |
95 type = obj.iType; |
|
96 |
96 if ((type ==ECmDefConnConnectionMethod) && (id == aMatchIapId)) |
97 if ((type ==ECmDefConnConnectionMethod) && (id == aMatchIapId)) |
97 { |
98 { |
|
99 CleanupStack::PopAndDestroy(mgr); |
98 return true; |
100 return true; |
99 } |
101 } |
100 else if (type != ECmDefConnDestination) |
102 else if (type != ECmDefConnDestination) |
101 { |
103 { |
|
104 CleanupStack::PopAndDestroy(mgr); |
102 return false; |
105 return false; |
103 } |
106 } |
104 } |
107 } |
105 |
108 |
106 RCmDestination tmpdst = mgr->DestinationL(id); |
109 RCmDestination tmpdst = mgr->DestinationL(id); |
107 ILOG1(ESOCKET,"Is connected return value = %d ", tmpdst.IsConnectedL()); |
110 ILOG1(ESOCKET,"Is connected return value = %d ", tmpdst.IsConnectedL()); |
|
111 |
|
112 CleanupStack::PopAndDestroy(mgr); |
|
113 |
108 if (!(tmpdst.IsConnectedL())) |
114 if (!(tmpdst.IsConnectedL())) |
109 { |
115 { |
110 return false; // no access point within this destination are active |
116 return false; // no access point within this destination are active |
111 } |
117 } |
112 for (TInt j = 0; j < tmpdst.ConnectionMethodCount(); j++) |
118 for (TInt j = 0; j < tmpdst.ConnectionMethodCount(); j++) |
136 |
140 |
137 RCmManager * mgr = new(ELeave) RCmManager(); |
141 RCmManager * mgr = new(ELeave) RCmManager(); |
138 mgr->OpenLC(); |
142 mgr->OpenLC(); |
139 TCmDefConnValue obj; |
143 TCmDefConnValue obj; |
140 HBufC8 * des; |
144 HBufC8 * des; |
141 |
|
142 |
145 |
143 mgr->ReadDefConnL(obj); |
146 mgr->ReadDefConnL(obj); |
144 id = obj.iId; |
147 id = obj.iId; |
145 type = obj.iType; |
148 type = obj.iType; |
146 LOG1(ESOCKET,EInfo,"readDefConnL returned %d",id); |
149 LOG1(ESOCKET,EInfo,"readDefConnL returned %d",id); |
147 LOG1(ESOCKET,EInfo,"type is %d",type); |
150 LOG1(ESOCKET,EInfo,"type is %d",type); |
148 CleanupStack::PopAndDestroy(); |
151 CleanupStack::PopAndDestroy(mgr); |
149 |
|
150 |
152 |
151 if (type == ECmDefConnAskOnce || type == ECmDefConnConnectionMethod || type == ECmDefConnDestination) |
153 if (type == ECmDefConnAskOnce || type == ECmDefConnConnectionMethod || type == ECmDefConnDestination) |
152 { |
154 { |
153 des = CreateDescriptorL(type,id); |
155 des = CreateDescriptorL(type,id); |
154 } |
156 } |
203 |
205 |
204 RGenConAgentDialogServer dlgSv; |
206 RGenConAgentDialogServer dlgSv; |
205 CleanupClosePushL(dlgSv); |
207 CleanupClosePushL(dlgSv); |
206 User::LeaveIfError(dlgSv.Connect()); |
208 User::LeaveIfError(dlgSv.Connect()); |
207 |
209 |
208 |
|
209 TRequestStatus status(KRequestPending); |
210 TRequestStatus status(KRequestPending); |
210 LOG(ESOCKET,EInfo,"prompting by regenconagent "); |
211 LOG(ESOCKET,EInfo,"prompting by regenconagent "); |
211 dlgSv.AccessPointConnection(dummy, dummy, snapOrIapId, prefs.iBearerSet, status); |
212 dlgSv.AccessPointConnection(dummy, dummy, snapOrIapId, prefs.iBearerSet, status); |
212 User::WaitForRequest(status); |
213 User::WaitForRequest(status); |
213 CleanupStack::PopAndDestroy(&dlgSv); |
214 CleanupStack::PopAndDestroy(&dlgSv); |
214 User::LeaveIfError(status.Int()); |
215 User::LeaveIfError(status.Int()); |
215 |
|
216 |
216 |
217 TMDBElementId tableId = snapOrIapId & KCDMaskShowRecordType; |
217 TMDBElementId tableId = snapOrIapId & KCDMaskShowRecordType; |
218 if (tableId == KCDTIdNetworkRecord) |
218 if (tableId == KCDTIdNetworkRecord) |
219 { |
219 { |
220 // User selects SNAP |
220 // User selects SNAP |
287 std::wstring temp; |
287 std::wstring temp; |
288 JavaStorageEntry attribute; |
288 JavaStorageEntry attribute; |
289 int snapid = KJavaNetworkAccessNotSpecified; |
289 int snapid = KJavaNetworkAccessNotSpecified; |
290 std::auto_ptr<JavaStorage> js(JavaStorage::createInstance()); |
290 std::auto_ptr<JavaStorage> js(JavaStorage::createInstance()); |
291 |
291 |
292 js->open(JAVA_DATABASE_NAME); |
292 try |
293 |
293 { |
294 |
294 js->open(JAVA_DATABASE_NAME); |
295 // Read all attributes of one application specified by UID. |
295 // Read all attributes of one application specified by UID. |
296 js->read(APPLICATION_PACKAGE_TABLE, aAppSuiteUid, entries); |
296 js->read(APPLICATION_PACKAGE_TABLE, aAppSuiteUid, entries); |
297 js->close(); |
297 js->close(); |
|
298 } |
|
299 catch (JavaStorageException& aJse) |
|
300 { |
|
301 LOG(ESOCKET,EInfo,"Attribute read failed."); |
|
302 } |
298 |
303 |
299 // set the entry as ACCESS_POINT |
304 // set the entry as ACCESS_POINT |
300 attribute.setEntry(ACCESS_POINT, L""); |
305 attribute.setEntry(ACCESS_POINT, L""); |
301 |
306 |
302 // Get value of the attribute from read attributes. |
307 // Get value of the attribute from read attributes. |
306 |
311 |
307 if (findIterator != entries.end() && findIterator->entryValue().length()>0 ) |
312 if (findIterator != entries.end() && findIterator->entryValue().length()>0 ) |
308 { |
313 { |
309 JavaStorageEntry sourceEntry = (*findIterator); |
314 JavaStorageEntry sourceEntry = (*findIterator); |
310 temp.append(sourceEntry.entryValue().c_str()); |
315 temp.append(sourceEntry.entryValue().c_str()); |
311 HBufC * value = S60CommonUtils::wstringToDes(temp.c_str()); |
316 std::auto_ptr<HBufC>value(S60CommonUtils::wstringToDes(temp.c_str())); |
312 HBufC8 * temp1 = HBufC8::NewL(value->Des().Length()); |
317 std::auto_ptr<HBufC8> temp1(HBufC8::NewL(value->Des().Length())); |
313 temp1->Des().Copy(value->Des()); |
318 temp1->Des().Copy(value->Des()); |
314 TRAP_IGNORE(snapid = ParseNetworkAccessPointL(*temp1)); |
319 TRAP_IGNORE(snapid = ParseNetworkAccessPointL(*temp1)); |
315 } |
320 } |
316 else |
321 else |
317 { |
322 { |
318 LOG(ESOCKET,EInfo,"Name attribute does not exists."); |
323 LOG(ESOCKET,EInfo,"Access point attribute does not exists."); |
319 } |
324 } |
320 entries.clear(); |
325 entries.clear(); |
321 } |
326 } |
322 return snapid; |
327 return snapid; |
323 } |
328 } |
445 { |
450 { |
446 des = CreateDescriptorL(ECmDefConnDestination,aSnapId); |
451 des = CreateDescriptorL(ECmDefConnDestination,aSnapId); |
447 } |
452 } |
448 } |
453 } |
449 |
454 |
450 HBufC* temp1 = HBufC::NewL(des->Des().Length()+1); |
455 std::auto_ptr<HBufC>temp1(HBufC::NewL(des->Des().Length()+1)); |
451 temp1->Des().Copy(des->Des()); |
456 temp1->Des().Copy(des->Des()); |
452 |
457 |
453 int len1 = des->Length(); |
458 int len1 = des->Length(); |
454 int len2 = temp1->Length(); |
459 int len2 = temp1->Length(); |
455 LOG2(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - len1= %d, len2 = %d",len1, len2); |
460 LOG2(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - len1= %d, len2 = %d",len1, len2); |
461 ptr16.Copy(ptr); |
466 ptr16.Copy(ptr); |
462 ptr16.SetLength(len2); |
467 ptr16.SetLength(len2); |
463 ptr16.ZeroTerminate(); |
468 ptr16.ZeroTerminate(); |
464 |
469 |
465 LOG1(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - len of apnString = %d", wcslen(apnString)); |
470 LOG1(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - len of apnString = %d", wcslen(apnString)); |
466 |
471 LOG1(ESOCKET,EInfo,"COnnectionManager::setApnIdL() - storing %S into javastorage", apnString); |
467 std::wstring tmpstring(apnString); |
|
468 char *dirName = JavaCommonUtils::wstringToUtf8(tmpstring); |
|
469 LOG1(ESOCKET,EInfo,"COnnectionManager::setApnIdL() - storing %s into javastorage",dirName); |
|
470 |
|
471 |
|
472 js->startTransaction(); |
|
473 |
472 |
474 attribute.setEntry(ACCESS_POINT, apnString); |
473 attribute.setEntry(ACCESS_POINT, apnString); |
475 updateEntries.insert(attribute); |
474 updateEntries.insert(attribute); |
476 |
475 |
477 attribute.setEntry(ID, aAppSuiteUid.toString()); |
476 attribute.setEntry(ID, aAppSuiteUid.toString()); |
478 matchEntries.insert(attribute); |
477 matchEntries.insert(attribute); |
479 |
478 |
|
479 delete [] apnString; |
480 |
480 |
481 LOG(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - before js update"); |
481 LOG(ESOCKET,EInfo,"ConnectionManager::setApnIdL() - before js update"); |
|
482 |
482 try |
483 try |
483 { |
484 { |
484 js->update(APPLICATION_PACKAGE_TABLE, updateEntries, matchEntries); |
485 js->update(APPLICATION_PACKAGE_TABLE, updateEntries, matchEntries); |
485 } |
486 } |
486 catch (JavaStorageException jse) |
487 catch (JavaStorageException jse) |
487 { |
488 { |
488 ELOG1(ESOCKET,"Updating the javastorage db failed %S",jse.toString().c_str()); |
489 ELOG1(ESOCKET,"Updating the javastorage db failed %S",jse.toString().c_str()); |
489 js->close(); |
|
490 CleanupStack::PopAndDestroy(des); |
|
491 return; |
|
492 } |
|
493 |
|
494 try |
|
495 { |
|
496 js->commitTransaction(); |
|
497 } |
|
498 catch (JavaStorageException jse) |
|
499 { |
|
500 ELOG(ESOCKET,"Commit transaction in javastorage db failed"); |
|
501 js->close(); |
490 js->close(); |
502 CleanupStack::PopAndDestroy(des); |
491 CleanupStack::PopAndDestroy(des); |
503 return; |
492 return; |
504 } |
493 } |
505 |
494 |