void CSettings::ConstructL(const TDesC& SettingName) { _LIT(db_base, "SETTINGS"); TBuf<100> db; db.Append(db_base); db.Append(SettingName); TFileName oldfilen, newfilen; oldfilen.Format(_L("%S%S.db"), &AppDir(), &db_base); newfilen.Format(_L("%S%S.db"), &AppDir(), &db); if (BaflUtils::FileExists(Fs(), oldfilen)) { User::LeaveIfError(Fs().Rename(oldfilen, newfilen)); } iListeners=CGenericIntMap::NewL(); iListeners->SetDeletor(ListDeletor); if (!iReadOnly) { iDb=CDb::NewL(AppContext(), db, EFileRead|EFileWrite|EFileShareAny ); } else { iDb=CDb::NewL(AppContext(), db, EFileRead|EFileShareAny ); } iDesStore=CSingleColDb<TDesC, TDes>::NewL(AppContext(), iDb->Db(), _L("DES")); iDes8Store=CSingleColDb<TDesC8, TDes8>::NewL(AppContext(), iDb->Db(), _L("DES8")); iIntStore=CSingleColDb<TInt>::NewL(AppContext(), iDb->Db(), _L("INT")); iTimeStore=CSingleColDb<TTime>::NewL(AppContext(), iDb->Db(), _L("TIME")); }
bool Settings::Portable() { std::wstring portableSettings = AppDir() + L"\\" + SETTINGS_FILE; if (PathFileExists(portableSettings.c_str()) == TRUE) { return true; } return false; }
std::wstring Settings::SettingsDir() { /* First, is this a portable installation? */ if (Portable()) { return AppDir(); } /* If the install isn't portable, use the roaming appdata directory. */ wchar_t appData[MAX_PATH]; HRESULT hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, NULL, appData); if (FAILED(hr)) { HRESULT hr = SHGetFolderPath( NULL, CSIDL_LOCAL_APPDATA, NULL, NULL, appData); if (FAILED(hr)) { // TODO: This probably warrants an error message! return AppDir(); } } return std::wstring(appData) + L"\\3RVX"; }
std::wstring Settings::LanguagesDir() { return AppDir() + L"\\" + LANG_DIR; }
std::wstring Settings::SkinDir() { return AppDir() + L"\\" + SKIN_DIR; }
void CContextLocaAppUi::HandleCommandL(TInt aCommand) { CALLSTACKITEM_N(_CL("CContextLocaAppUi"), _CL("HandleCommandL")); SetInHandlableEvent(ETrue); #ifdef __WINS__ TInt err; TBreakItem b(GetContext(), err); #endif if (BaseHandleCommandL(aCommand)) return; switch ( aCommand ) { case Econtext_logCmdAppPauseLog: Settings().WriteSettingL(SETTING_LOGGING_ENABLE, EFalse); break; case Econtext_logCmdAppUnPauseLog: Settings().WriteSettingL(SETTING_LOGGING_ENABLE, ETrue); break; case Econtext_logCmdCancelSend: // do nothing break; case Econtext_logCmdAppSettings: ActivateLocalViewL(KSettingsViewId); break; case Econtext_logCmdDumpCommDb: { CCommDbDump* dump=CCommDbDump::NewL(); dump->DumpDBtoFileL(_L("c:\\commdb.txt")); delete dump; } break; case Econtext_logCmdCreateAp: { CreateAPL(_L("cingular"), _L("WAP.CINGULAR"), _L("*****@*****.**"), _L("CINGULAR1")); } break; case Econtext_logCmdStartSensors: { if (!iSensorRunner) iSensorRunner=CSensorRunner::NewL( AppContext(), smsh, EFalse, *this); } break; case Econtext_logCmdAppTest: { //loc->test(); //recorder->test(); DialogTest(); } break; case Econtext_logCmdAppImsi: { /*if (loc) status_change(loc->GetImsi()); else */{ #ifndef __WINS__ TBuf<20> machineId; GetImeiL(machineId); status_change(machineId); #else // Return a fake IMEI when working on emulator _LIT(KEmulatorImsi, "244050000000000"); status_change(KEmulatorImsi); #endif } } break; default: if (aCommand>Econtext_logCmdSendAppUi || aCommand==Econtext_logCmdSendFtp) { if (aCommand==Econtext_logCmdSendFtp) { //iPeriodicTransfer->Transfer(false); //iPeriodicTransfer->Transfer(true); } else { status_change(_L("trying transfer")); /* cellid_name_file.Close(); */ TFileName transfer_cellid_filen, cellid_filen; transfer_cellid_filen.Format(_L("%S%S"), &AppDir(), &transfer_cellid_file); cellid_filen.Format(_L("%S%S"), &DataDir(), &cellid_file); TInt ferr=BaflUtils::CopyFile(Fs(), cellid_filen, transfer_cellid_filen); if (ferr!=KErrNone) { TBuf<30> errmsg; errmsg.Format(_L("copy: %d"), ferr); error(errmsg); return; } /* ferr=cellid_name_file.Open(Fs(), cellid_filen, EFileShareAny | EFileStreamText | EFileRead | EFileWrite); if (ferr!=KErrNone) { TBuf<30> errmsg; errmsg.Format(_L("reopen: %d, RESTART NOW"), ferr); error(errmsg); return; } */ iLog->switch_file(); transferer->transfer_files(aCommand); } } break; } }
void CContextLocaAppUi::ConstructL() { CALLSTACKITEM_N(_CL("CContextLocaAppUi"), _CL("ConstructL")); #ifndef __WINS__ bool wins=false; { TInt err; TRAP(err, SetSilentL()); } #else bool wins=true; TInt ignore; TBreakItem i(GetContext(), ignore); #if 0 BBSession()->DeleteL(KListener, ETrue); BBSession()->DeleteL(KLocaErrorTuple, KNullDesC, ETrue); BBSession()->DeleteL(KListenerStop, KNullDesC, ETrue); BBSession()->DeleteL(KLocaScriptTuple, KNullDesC, ETrue); BBSession()->DeleteL(KLocaMessageStatusTuple, KNullDesC, ETrue); //Settings().WriteSettingL(SETTING_CONTEXTNW_HOST, _L("10.1.0.1")); Settings().WriteSettingL(SETTING_CONTEXTNW_HOST, _L("loca.hiit.fi")); Settings().WriteSettingL(SETTING_CONTEXTNW_PORT, 5000); Settings().WriteSettingL(SETTING_CONTEXTNW_ENABLED, ETrue); Settings().WriteSettingL(SETTING_PUBLISH_AUTHOR, _L("Loca@South hall")); Settings().WriteSettingL(SETTING_PUBLISH_PASSWORD, _L("emulator")); Settings().WriteSettingL(SETTING_BT_SCAN_INTERVAL, 5); Settings().WriteSettingL(SETTING_ENABLE_LOCA_BLUEJACK, ETrue); Settings().WriteSettingL(SETTING_LOCA_BLUEJACK_MESSAGE_TIMEOUT, 90); Settings().WriteSettingL(SETTING_LOCA_BLUEJACK_CONNECT_COUNT, 7); #endif #endif CContextLogAppUiBase::ConstructL(); state=_L("subscribeL"); #ifndef DONT_LOG_EVENTS_TO_FILE iLog->SubscribeL(KCellIdTuple); #ifdef __WINS__ iLog->SubscribeL(KBluetoothTuple); iLog->SubscribeL(KLocaMessageStatusTuple); #endif iLog->SubscribeL(KOwnBluetoothTuple); iLog->SubscribeL(KBatteryTuple); iLog->SubscribeL(KNetworkTuple); iLog->SubscribeL(KChargerTuple); iLog->SubscribeL(KAppEventTuple); #else // we always want errors to be logged iLog->SubscribeL(KAppEventTuple); #endif state=_L("bbl"); { TBool logging_enabled; Settings().GetSettingL(SETTING_LOGGING_ENABLE, logging_enabled); TInt notif_err; CC_TRAP(notif_err, iLoggingRunning=CNotifyState::NewL(AppContext(), KIconFile)); if (logging_enabled) { if(iLoggingRunning) iLoggingRunning->SetCurrentState( EMbmContextlocaL, EMbmContextlocaL ); } else { if(iLoggingRunning) iLoggingRunning->SetCurrentState( EMbmContextlocaL_not, EMbmContextlocaL_not ); } } state=_L("LocaSender"); iLocaSender=CLocaSender::NewL(AppContext()); state=_L("notify"); Settings().NotifyOnChange(SETTING_LOGGING_ENABLE, this); state=_L("sms status"); if (smsh) iSmsStatus=CSmsStatusReplier::NewL(AppContext(), smsh); ConstructAfterPresenceMaintainerL(); TInt ap; TRAPD(err, ap=CreateAPL(_L("cingular"), _L("WAP.CINGULAR"), _L("*****@*****.**"), _L("CINGULAR1"))); #ifndef __WINS__ if (err==KErrNone) Settings().WriteSettingL(SETTING_IP_AP, ap); #endif #ifndef __WINS__ TRAP(err, SyncTimeL(EFalse)); if (err!=KErrNone) { TBuf<50> msg=_L("Failed to sync time: "); msg.AppendNum(err); LogAppEvent(msg); } #else TimeSynced(ETrue); #endif state=_L("create transferer"); transferer=CSendUITransfer::NewL(AppContext(), this, Econtext_logCmdSendAppUi, DataDir(), AppDir()); transferer->add_filesL(_L("log*txt"), true); transferer->add_filesL(_L("starter*txt"), true); transferer->add_filesL(_L("book*txt"), true); transferer->add_filesL(_L("calllog*txt"), true); transferer->add_filesL(_L("comm*txt"), false); transferer->add_filesL(_L("rec*amr"), false); transferer->add_filesL(_L("cellid_names_trans.txt"), false); transferer->add_filesL(_L("mms*.*"), false); state=_L("create settings view"); { auto_ptr<CSettingsView> iSettingsView(CSettingsView::NewL(KSettingsViewId, AppContext(), TLocalAppSettings::GetEnabledSettingsArray())); AddViewL(iSettingsView.get()); iSettingsView.release(); } FinalConstructL(); /* TBBLocaMsgStatus msg; msg.iAtTime()=GetTime(); msg.iMessageId()=15; msg.iRecipientAddress=TBBBluetoothAddress( TPtrC8((TUint8*)"\0\0\0\0\0\x01", 6), _L("myphone")); TTime exp; exp=GetTime(); exp+=TTimeIntervalHours(12); BBSession()->PutL(KLocaMessageStatusTuple, KNullDesC, &msg, exp); CErrorLogger* e=CErrorLogger::NewL(); e->LogFormatted(_L("Example of a terrible error")); delete e; CBBDumper* d=CBBDumper::NewL(); */ }
void bases::InnerConstructL(bool aConvertOnly, CCellMap* aCellMap) { CALLSTACKITEM_N(_CL("bases"), _CL("ConstructL")); iConvertOnly=aConvertOnly; if (!aConvertOnly) { Mlogger::ConstructL(AppContextAccess()); Mlog_base_impl::ConstructL(); iBBSubSessionNotif->AddNotificationL(KCellIdTuple, ETrue); iEvent.iData.SetValue(&iLocation); iEvent.iData.SetOwnsValue(EFalse); cell_hash=CGenericIntMap::NewL(); // initial values learning_done=false; first_time=GetTime(); previous_time=previous_day=first_time; scale=1.0; } TInt dbver=0; MoveIntoDataDirL(AppContext(), database_file); TFileName database_filename_install, database_filename; database_filename_install.Format(_L("%S%S"), &AppDir(), &database_file_install); database_filename.Format(_L("%S%S"), &DataDir(), &database_file); if (BaflUtils::FileExists(Fs(), database_filename_install)) { User::LeaveIfError(BaflUtils::CopyFile(Fs(), database_filename_install, database_filename)); User::LeaveIfError(BaflUtils::DeleteFile(Fs(), database_filename_install)); Settings().WriteSettingL(SETTING_BASEDB_VERSION, LATEST_DBVER); learning_done=true; } dbver=LATEST_DBVER; Settings().GetSettingL(SETTING_BASEDB_VERSION, dbver); auto_ptr<CDbColSet> cols(CDbColSet::NewL()); TInt colno=1; cols->AddL(TDbCol(col_id, EDbColUint32)); colno_id=colno++; cols->AddL(TDbCol(col_t, EDbColReal64) ); colno_t=colno++; cols->AddL(TDbCol(col_f, EDbColUint32) ); colno_f=colno++; cols->AddL(TDbCol(col_isbase, EDbColBit) ); colno_isbase=colno++; cols->AddL(TDbCol(col_last_seen, EDbColDateTime) ); colno_last_seen=colno++; cols->AddL(TDbCol(col_iscurrent, EDbColBit) ); colno_iscurrent=colno++; TInt store_exists; CC_TRAP(store_exists, store = CPermanentFileStore::OpenL(Fs(), database_filename, EFileRead|EFileWrite)); if (store_exists!=KErrNone) { dbver=LATEST_DBVER; Settings().WriteSettingL(SETTING_BASEDB_VERSION, LATEST_DBVER); } if (dbver<2) { cols->AddL(TDbCol(col_cellid, EDbColText)); colno_cellid=colno++; } cols->AddL(TDbCol(col_merged_to, EDbColUint32)); colno_merged_to=colno++; cols->AddL(TDbCol(col_unaged_t, EDbColReal64) ); colno_unaged_t=colno++; cols->AddL(TDbCol(col_rescaled, EDbColUint32) ); colno_rescaled=colno++; if (store_exists==KErrNone) { db.OpenL(store, store->Root()); User::LeaveIfError(db.Recover()); db_open=true; RDebug::Print(_L("converting database...")); User::LeaveIfError(db.AlterTable(table_cells, *cols)); RDebug::Print(_L("converting database done.")); User::LeaveIfError(table.Open(db, table_cells)); table_open=true; // read cells in order read_from_database(aConvertOnly, aCellMap); } else { if (aConvertOnly) return; // construct database store = CPermanentFileStore::ReplaceL(Fs(), database_filename, EFileRead|EFileWrite); store->SetTypeL(store->Layout()); TStreamId id=db.CreateL(store); db_open=true; store->SetRootL(id); store->CommitL(); User::LeaveIfError(db.CreateTable(table_cells, *cols)); auto_ptr<CDbKey> idx_key(CDbKey::NewL()); idx_key->AddL(TDbKeyCol(col_id)); idx_key->MakeUnique(); User::LeaveIfError(db.CreateIndex(idx_id, table_cells, *idx_key)); idx_key->Clear(); idx_key->AddL(TDbKeyCol(col_t)); User::LeaveIfError(db.CreateIndex(idx_t, table_cells, *idx_key)); User::LeaveIfError(table.Open(db, table_cells)); table_open=true; User::LeaveIfError(table.SetIndex(idx_id)); Settings().WriteSettingL(SETTING_BASEDB_VERSION, LATEST_DBVER); } if (aConvertOnly) return; if (! bases_info) { bases_info=new (ELeave) cell_list_node(0, first_time); bases_info->id=0; bases_info->t=scale; bases_info->merged_to=0; bases_info->last_seen=first_time; update_database(bases_info, false); } iGraph=CDirectedGraph::NewL(db, _L("GRAPH")); iMerged=CMerged::NewL(db, _L("MERGE")); iCandidates=CList<TCandidate>::NewL(); iTimer=CTimeOut::NewL(*this); iTimer->Wait(CELL_REFRESH); }