bool TDBTBL::OpenDB(PGLOBAL g) { if (trace) htrc("TBL OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n", this, Tdb_No, Use, To_Key_Col, Mode); if (Use == USE_OPEN) { /*******************************************************************/ /* Table already open, replace it at its beginning. */ /*******************************************************************/ ResetDB(); return Tdbp->OpenDB(g); // Re-open fist table } // endif use /*********************************************************************/ /* When GetMaxsize was called, To_CondFil was not set yet. */ /*********************************************************************/ if (To_CondFil && Tablist) { Tablist = NULL; Nbc = 0; } // endif To_CondFil /*********************************************************************/ /* Open the first table of the list. */ /*********************************************************************/ if (!Tablist && InitTableList(g)) // done in GetMaxSize return TRUE; if ((CurTable = Tablist)) { Tdbp = (PTDBASE)CurTable->GetTo_Tdb(); // Tdbp->SetMode(Mode); // Tdbp->ResetDB(); // Tdbp->ResetSize(); // Check and initialize the subtable columns for (PCOL cp = Columns; cp; cp = cp->GetNext()) if (cp->GetAmType() == TYPE_AM_TABID) cp->COLBLK::Reset(); else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept) return TRUE; if (trace) htrc("Opening subtable %s\n", Tdbp->GetName()); // Now we can safely open the table if (Tdbp->OpenDB(g)) return TRUE; } // endif *Tablist Use = USE_OPEN; return FALSE; } // end of OpenDB
void CPodcastModel::ConstructL() { DP("CPodcastModel::ConstructL BEGIN"); User::LeaveIfError(iFsSession.Connect()); iCommDB = CCommsDatabase::NewL (EDatabaseTypeUnspecified); iIapNameArray = new (ELeave) CDesCArrayFlat(KDefaultGranu); iSNAPNameArray = new (ELeave) CDesCArrayFlat(KDefaultGranu); iImageHandler = CImageHandler::NewL(FsSession(), *this); iDocHandler = CDocumentHandler::NewL(CEikonEnv::Static()->Process()); TRAPD(err,iCmManager.OpenL()); DP1("iCmManager.OpenL(),err=%d;", err); if (err == KErrNone) { UpdateIAPListL(); UpdateSNAPListL(); } iSettingsEngine = CSettingsEngine::NewL(*this); iConnectionEngine = CConnectionEngine::NewL(*this); TRAP(err, OpenDBL()); if (err != KErrNone) { ResetDB(); TRAP(err, OpenDBL()); if (err != KErrNone) { Panic(EPodcatcherPanicDB); } } iFeedEngine = CFeedEngine::NewL(*this); iShowEngine = CShowEngine::NewL(*this); DP("CPodcastModel::ConstructL END"); }
//int WINAPI WinMain (HINSTANCE hInstance, // HINSTANCE hPrevInstance, // LPSTR lpCmdLine, // int nShowCmd) VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv) { char ConnectionName[15]; /*------------------------------------------------------------*/ /* Modification: Migration from single thread to multithread */ /* Create thread calls are changed to _beginthread */ /* XID on 7-DEC-1998 */ /*------------------------------------------------------------*/ // DWORD CreateThreadId; char StrAux[128]; int CommServerNumber; int LoggerRouteId, CommServerRouteId; char *pStringSub[2]; BYTE CommServerRedundant; BYTE DBServiceDepending; BYTE CommServerPreferred; // report the status to the service control manager. // if (!ReportStatusToSCMgr (SERVICE_START_PENDING, // service state NO_ERROR, // exit code 3000)) // wait hint return; /* Create the event to stop the service */ hStopEvent = CreateEvent (NULL, TRUE, FALSE, NULL); /*-----------------*/ /* Init. procedure */ /*-----------------*/ /* Sets process priority (Normal class) */ SetPriorityClass (GetCurrentProcess (), NORMAL_PRIORITY_CLASS); /* Modification: Process parameters are got from system registry */ /* XID on 16-JUL-1998 */ /* Get the CommServer Number CommServer.Ini */ //CommServerNumber = GetPrivateProfileInt ("GENERAL", "CommServerId", 0,"CommServer.ini"); if (!GetParameterRegistry (COMM_NUM_COMMSERVER, (unsigned char *) &CommServerNumber)) { CommServerNumber = 0; } /* endif */ /* Get the redundant configuration from the system registry */ if (!GetParameterRegistry (COMM_REDUNDANT_CONFIGURATION, (unsigned char *) &CommServerRedundant)) { CommServerRedundant = FALSE; } /* endif */ /* Get the redundant configuration from the system registry */ if (!GetParameterRegistry (COMM_DBSERVICE_DEPENDING, (unsigned char *) &DBServiceDepending)) { DBServiceDepending = TRUE; } /* endif */ if (!GetParameterRegistry (COMM_COMMSERVER_PREFERRED, (unsigned char *) &CommServerPreferred)) { CommServerPreferred = TRUE; } /* endif */ /*-------------------------------*/ /* Basic Network init. procedure */ /*-------------------------------*/ /* Initialize interproccess communication */ if (!RouterInit ()) { /* Error */ AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_STD_ROUTER_FAILED); return; } /* endif */ /* Detailed Logging initialization */ (void) Log_SetProcessName("CommS"); (void) Log_SetThreadName("SrvcMain"); /* Get connection to send logger messages */ sprintf (ConnectionName, "LOGGER%03u", 0); if (!GetConnection (ConnectionName, &LoggerRouteId)) { /* Error */ pStringSub[0] = ConnectionName; AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_STD_GET_CONECTION_ERROR); return; } /* endif */ /* Create connection to receive online messages from DBService */ sprintf (ConnectionName, "COMSERV%03u", CommServerNumber); if (!CreateConnection (ConnectionName, &CommServerRouteId)) { /* Error */ pStringSub[0] = ConnectionName; AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_STD_CREATE_CONECTION_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (LoggerRouteId, -1, StrAux, 1); return; } /* endif */ /* Start & version message */ LogWrite (LoggerRouteId, CommServerRouteId, "", 1); sprintf (StrAux, CS_LOG_MSG_00036, COMM_SERVER_BUILD_NUMBER, COMM_SERVER_VERSION_DATE); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); sprintf (StrAux, CS_LOG_MSG_00109); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); sprintf (StrAux, CS_LOG_MSG_00037); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); #if defined (HASP_KEY) sprintf (StrAux, COMM_SERVER_HASP_ON_STR); #else sprintf (StrAux, COMM_SERVER_HASP_OFF_STR); #endif LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); #if defined (PROT_CONV_LAYER) sprintf (StrAux, COMM_SERVER_CONV_ON_STR); #else sprintf (StrAux, COMM_SERVER_CONV_OFF_STR); #endif LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); #if defined (PROT_ENCRYPTION) sprintf (StrAux, COMM_SERVER_ENC_ON_STR); #else sprintf (StrAux, COMM_SERVER_ENC_OFF_STR); #endif LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); #if defined (PROT_COMPRESSION) sprintf (StrAux, COMM_SERVER_COMP_ON_STR); #else sprintf (StrAux, COMM_SERVER_COMP_OFF_STR); #endif LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); /* Commserver Id */ sprintf (StrAux, CS_LOG_MSG_00110, CommServerNumber); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); LogWrite (LoggerRouteId, CommServerRouteId, "", 1); /* Redundant configuration */ if (CommServerRedundant) { sprintf (StrAux, CS_LOG_MSG_00125); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); sprintf (StrAux, CS_LOG_MSG_00124 ,CommServerPreferred ,DBServiceDepending); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); LogWrite (LoggerRouteId, CommServerRouteId, "", 1); } /* endif */ /* Set input buffer size for this route. */ /* This input buffer has to be large enough */ /* to receive all the incomming messages */ SetInputBufferSize (CommServerRouteId, COMMSERVER_CONNECTION_INPUT_BUFFER_SIZE); /*---------------------*/ /* DB access semaphore */ /*---------------------*/ if (!InitDBSection ()) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00038); printf ("%s\n", StrAux); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); //AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM, // EVLG_COMMSERVER_MAP_MEMORY_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); return; } /* endif */ /*--------------------*/ /* Map channel memory */ /*--------------------*/ if (InitChannelMapData () != STATUS_OK) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00039); printf ("%s\n", StrAux); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_COMMSERVER_MAP_MEMORY_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (LoggerRouteId, CommServerRouteId, StrAux, 1); return; } /* endif */ /* Reset CommServer database */ ResetDB (); /* Assign comm. server id. and basic routes */ DB_PROCESS.CommServerNumber = CommServerNumber; DB_PROCESS.LoggerRouteId = LoggerRouteId; DB_PROCESS.CommServerRouteId = CommServerRouteId; /* CommServer redundancy initial state */ DB_PROCESS.CommServerPartnerState = PROCESS_STATE_NORUNNING; DB_PROCESS.CommServerState = PROCESS_STATE_NORUNNING; DB_PROCESS.DBServiceDepending = DBServiceDepending; DB_PROCESS.CommServerPreferred = CommServerPreferred; #if defined (HASP_KEY) /* Default hasp check */ DB_PROCESS.HaspPresent = TRUE; #endif /*-------------*/ /* MGL license */ /*-------------*/ MGL_ReadLicense (); /*------------------------*/ /* Compression algorithms */ /*------------------------*/ Util_SplayTreeCompressInit (NULL); Util_SplayTreeUncompressInit (NULL); /*--------------------------*/ /* Process critical secions */ /*--------------------------*/ InitializeCriticalSection (&DB_PROCESS.CSFreeChannels); InitializeCriticalSection (&DB_PROCESS.CSFreeNetworkThreads); InitializeCriticalSection (&DB_PROCESS.CSModifyCfg); /*---------------------------*/ /* Other Network connections */ /*---------------------------*/ /* Get connection to send message to DBService */ sprintf (ConnectionName, "DBCOMM%03u", 0); if (!GetConnection (ConnectionName, &DB_PROCESS.DBServiceRouteId)) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00041, ConnectionName); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); pStringSub[0] = ConnectionName; AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_STD_GET_CONECTION_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); return; } /* endif */ /* Get connection to send confirm messages */ sprintf (ConnectionName, "DBCONF%03u", 0); if (!GetConnection (ConnectionName, &DB_PROCESS.DBConfirmRouteId)) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00041, ConnectionName); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); pStringSub[0] = ConnectionName; AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_STD_GET_CONECTION_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); return; } /* endif */ /* Get connection to send confirm messages */ sprintf (ConnectionName, "DBSEQ%03u", 0); if (!GetConnection (ConnectionName, &DB_PROCESS.DBSeqRouteId)) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00041, ConnectionName); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); pStringSub[0] = ConnectionName; AddToMessageLog (pStringSub, 1, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_STD_GET_CONECTION_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); return; } /* endif */ /* Initialize Network layer */ if (!NetworkInit ()) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00042); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_COMMSERVER_NETWORK_LAYER_INIT_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); return; } /* endif */ /*------------------*/ /* Threads creation */ /*------------------*/ /*------------------------------------------------------------*/ /* Modification: Migration from single thread to multithread */ /* Create thread calls are changed to _beginthread */ /* XID on 7-DEC-1998 */ /*------------------------------------------------------------*/ /* Create thread to receive messages from the DbService */ // if (CreateThread (NULL, MAX_STACK, (LPTHREAD_START_ROUTINE) HostToTermThread, // (LPVOID) NULL, 0, &CreateThreadId) == NULL) if (_beginthread (HostToTermThread, MAX_STACK, (LPVOID) NULL) == -1) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00043); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_STD_CREATE_THREAD_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); return; } /* endif */ /* Create thread to check channels integrity */ // if (CreateThread (NULL, MAX_STACK, (LPTHREAD_START_ROUTINE) CheckChannelsThread, // (LPVOID) NULL, 0, &CreateThreadId) == NULL) if (_beginthread (CheckChannelsThread, MAX_STACK, (LPVOID) NULL) == -1) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00045); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_STD_CREATE_THREAD_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); return; } /* endif */ /* If the redundancy is configured create the failover thread */ if (CommServerRedundant) { if (_beginthread (FailOverThread, MAX_STACK, (LPVOID) NULL) == -1) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00045); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_STD_CREATE_THREAD_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); return; } /* endif */ } else { /* In not redundancy case it is always active */ DB_PROCESS.CommServerState = PROCESS_STATE_ACTIVE; } /* endif */ /*--------------------------*/ /* CommServer configuration */ /*--------------------------*/ /* Offline parameters */ if (!ReadOfflineDir ()) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00046); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_COMMSERVER_OFFLINE_DIR_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); return; } /* endif */ /* Configuration message */ sprintf (StrAux, CS_LOG_MSG_00047); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 5); // report the status to the service control manager. // if (!ReportStatusToSCMgr (SERVICE_RUNNING, // service state NO_ERROR, // exit code 3000)) // wait hint { sprintf (StrAux, CS_LOG_MSG_00048); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); return; } /* endif */ // XID on 17/OCT/2002 // X25 support X25_Init (); /* Start message */ AddToMessageLog (NULL, 0, EVENTLOG_INFORMATION_TYPE, SC_SYSTEM, EVLG_STD_SERVICE_STARTED); /* Get configuration from DBService */ if (!RemoteConfiguration ()) //if (!ConfigureApp ()) { /* Error */ sprintf (StrAux, CS_LOG_MSG_00049); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); AddToMessageLog (NULL, 0, EVENTLOG_ERROR_TYPE, SC_SYSTEM, EVLG_COMMSERVER_LOAD_CONFIG_ERROR); sprintf (StrAux, CS_LOG_MSG_00035); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 1); /* Write the last status in the system registry */ if (CommServerRedundant) { GetStatusFromPartnerStatus (PROCESS_STATE_NORUNNING, DB_PROCESS.CommServerState, DB_PROCESS.CommServerPartnerState); } /* endif */ return; } /* endif */ /* Sets main thread to idle priority */ SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE); /* Configuration message */ sprintf (StrAux, CS_LOG_MSG_00050); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, StrAux, 5); /*-----------------------------*/ /* Wait for the the stop event */ /*-----------------------------*/ WaitForSingleObject (hStopEvent, INFINITE); LogWrite (DB_PROCESS.LoggerRouteId, DB_PROCESS.CommServerRouteId, CS_LOG_MSG_00051, 1); /* Write the last status in the system registry */ if (CommServerRedundant) { GetStatusFromPartnerStatus (PROCESS_STATE_NORUNNING, DB_PROCESS.CommServerState, DB_PROCESS.CommServerPartnerState); } /* endif */ AddToMessageLog (NULL, 0, EVENTLOG_INFORMATION_TYPE, SC_SYSTEM, EVLG_STD_SERVICE_STOPPED); return; } /* main */