/*! \brief Overrides the super class version to avoid termination of the registrar until the system shutdown. */ bool Registrar::QuitRequested() { FUNCTION_START(); // The final registrar must not quit. At least not that easily. ;-) return BApplication::QuitRequested(); }
static void GPKG_IsAssignable(sqlite3_context *context, int nbArgs, sqlite3_value **args) { FUNCTION_TEXT_ARG(expected_type_name); FUNCTION_TEXT_ARG(actual_type_name); FUNCTION_START(context); FUNCTION_GET_TEXT_ARG(context, expected_type_name, 0); FUNCTION_GET_TEXT_ARG(context, actual_type_name, 1); geom_type_t expected_type; FUNCTION_RESULT = geom_type_from_string(expected_type_name, &expected_type); if (FUNCTION_RESULT != SQLITE_OK) { error_append(FUNCTION_ERROR, "Invalid geometry type %s", expected_type_name); goto exit; } geom_type_t actual_type; FUNCTION_RESULT = geom_type_from_string(actual_type_name, &actual_type); if (FUNCTION_RESULT != SQLITE_OK) { error_append(FUNCTION_ERROR, "Invalid geometry type %s", actual_type_name); goto exit; } sqlite3_result_int(context, geom_is_assignable(expected_type, actual_type)); FUNCTION_END(context); FUNCTION_FREE_TEXT_ARG(expected_type_name); FUNCTION_FREE_TEXT_ARG(actual_type_name); }
/*! \brief Overrides the super class version to initialize the registrar services. */ void Registrar::ReadyToRun() { FUNCTION_START(); // create event queue fEventQueue = new EventQueue(kEventQueueName); // create roster fRoster = new TRoster; fRoster->Init(); // create clipboard handler fClipboardHandler = new ClipboardHandler; AddHandler(fClipboardHandler); // create MIME manager fMIMEManager = new MIMEManager; fMIMEManager->Run(); // create message runner manager fMessageRunnerManager = new MessageRunnerManager(fEventQueue); // init the global be_roster BRoster::Private().SetTo(be_app_messenger, BMessenger(NULL, fMIMEManager)); // create and schedule the sanity message event fSanityEvent = new MessageEvent(system_time() + kRosterSanityEventInterval, this, B_REG_ROSTER_SANITY_EVENT); fSanityEvent->SetAutoDelete(false); fEventQueue->AddEvent(fSanityEvent); FUNCTION_END(); }
static void GPKG_SpatialDBType(sqlite3_context *context, int nbArgs, sqlite3_value **args) { spatialdb_t *spatialdb; FUNCTION_START(context); spatialdb = (spatialdb_t *)sqlite3_user_data(context); sqlite3_result_text(context, spatialdb->name, -1, SQLITE_STATIC); FUNCTION_END(context); }
/*! \brief Creates the registrar application class. */ Registrar::Registrar() : BApplication(kRegistrarSignature), fRoster(NULL), fClipboardHandler(NULL), fMIMEManager(NULL), fEventQueue(NULL), fMessageRunnerManager(NULL), fSanityEvent(NULL) { FUNCTION_START(); }
/*! \brief Creates and runs the registrar application. The main thread is renamed. \return 0. */ int main() { FUNCTION_START(); // rename the main thread rename_thread(find_thread(NULL), kRosterThreadName); // create and run the registrar application Registrar *app = new Registrar(); PRINT(("app->Run()...\n")); app->Run(); PRINT(("delete app...\n")); delete app; FUNCTION_END(); return 0; }
static void GPKG_CreateSpatialIndex(sqlite3_context *context, int nbArgs, sqlite3_value **args) { spatialdb_t *spatialdb; FUNCTION_TEXT_ARG(db_name); FUNCTION_TEXT_ARG(table_name); FUNCTION_TEXT_ARG(geometry_column_name); FUNCTION_TEXT_ARG(id_column_name); FUNCTION_START(context); spatialdb = (spatialdb_t *)sqlite3_user_data(context); if (nbArgs == 4) { FUNCTION_GET_TEXT_ARG(context, db_name, 0); FUNCTION_GET_TEXT_ARG(context, table_name, 1); FUNCTION_GET_TEXT_ARG(context, geometry_column_name, 2); FUNCTION_GET_TEXT_ARG(context, id_column_name, 3); } else { FUNCTION_SET_TEXT_ARG(db_name, "main"); FUNCTION_GET_TEXT_ARG(context, table_name, 0); FUNCTION_GET_TEXT_ARG(context, geometry_column_name, 1); FUNCTION_GET_TEXT_ARG(context, id_column_name, 2); } if (spatialdb->create_spatial_index == NULL) { error_append(FUNCTION_ERROR, "Spatial indexes are not supported in %s mode", spatialdb->name); goto exit; } FUNCTION_START_TRANSACTION(__create_spatial_index); FUNCTION_RESULT = spatialdb->init_meta(FUNCTION_DB_HANDLE, db_name, FUNCTION_ERROR); if (FUNCTION_RESULT == SQLITE_OK) { FUNCTION_RESULT = spatialdb->create_spatial_index(FUNCTION_DB_HANDLE, db_name, table_name, geometry_column_name, id_column_name, FUNCTION_ERROR); } FUNCTION_END_TRANSACTION(__create_spatial_index); if (FUNCTION_RESULT == SQLITE_OK) { sqlite3_result_null(context); } FUNCTION_END(context); FUNCTION_FREE_TEXT_ARG(db_name); FUNCTION_FREE_TEXT_ARG(table_name); FUNCTION_FREE_TEXT_ARG(geometry_column_name); FUNCTION_FREE_TEXT_ARG(id_column_name); }
/*! \brief Frees all resources associated with the registrar. All registrar services, that haven't been shut down earlier, are terminated. */ Registrar::~Registrar() { FUNCTION_START(); Lock(); fEventQueue->Die(); delete fMessageRunnerManager; delete fEventQueue; delete fSanityEvent; fMIMEManager->Lock(); fMIMEManager->Quit(); RemoveHandler(fClipboardHandler); delete fClipboardHandler; delete fRoster; // Invalidate the global be_roster, so that the BApplication destructor // won't dead-lock when sending a message to itself. BRoster::Private().SetTo(BMessenger(), BMessenger()); FUNCTION_END(); }
static void GPKG_CheckSpatialMetaData(sqlite3_context *context, int nbArgs, sqlite3_value **args) { spatialdb_t *spatialdb; FUNCTION_TEXT_ARG(db_name); FUNCTION_INT_ARG(check); FUNCTION_INT_ARG(type); FUNCTION_START(context); spatialdb = (spatialdb_t *)sqlite3_user_data(context); if (nbArgs == 0) { FUNCTION_SET_TEXT_ARG(db_name, "main"); FUNCTION_SET_INT_ARG(check, 0); } else if (nbArgs == 1) { FUNCTION_GET_TYPE(type, 0); if (type == SQLITE_TEXT) { FUNCTION_GET_TEXT_ARG(context, db_name, 0); } else { FUNCTION_SET_TEXT_ARG(db_name, "main"); FUNCTION_GET_INT_ARG(check, 0); } } else { FUNCTION_GET_TEXT_ARG(context, db_name, 0); FUNCTION_GET_INT_ARG(check, 1); } if (check != 0) { check = SQL_CHECK_ALL; } FUNCTION_RESULT = spatialdb->check_meta(FUNCTION_DB_HANDLE, db_name, check, FUNCTION_ERROR); if (FUNCTION_RESULT == SQLITE_OK) { sqlite3_result_null(context); } FUNCTION_END(context); FUNCTION_FREE_TEXT_ARG(db_name); FUNCTION_FREE_INT_ARG(check); FUNCTION_FREE_INT_ARG(type); }
static void GPKG_LoadGEOS(sqlite3_context *context, int nbArgs, sqlite3_value **args) { geos_context_t *ctx = NULL; spatialdb_t *spatialdb; FUNCTION_TEXT_ARG(lib_path); FUNCTION_START(context); spatialdb = (spatialdb_t *)sqlite3_user_data(context); if (sqlite3_value_type(args[0]) != SQLITE_NULL) { FUNCTION_GET_TEXT_ARG_UNSAFE(lib_path, 0); } ctx = geos_context_init(spatialdb, lib_path, FUNCTION_ERROR); if (ctx != NULL) { geom_func_register(FUNCTION_DB_HANDLE, FUNCTION_ERROR, ctx); } FUNCTION_END(context); FUNCTION_FREE_TEXT_ARG(lib_path); if (ctx != NULL) { geos_context_release(ctx); } }
static void GPKG_InitSpatialMetaData(sqlite3_context *context, int nbArgs, sqlite3_value **args) { spatialdb_t *spatialdb; FUNCTION_TEXT_ARG(db_name); FUNCTION_START(context); spatialdb = (spatialdb_t *)sqlite3_user_data(context); if (nbArgs == 0) { FUNCTION_SET_TEXT_ARG(db_name, "main"); } else { FUNCTION_GET_TEXT_ARG(context, db_name, 0); } FUNCTION_START_TRANSACTION(__initspatialdb); FUNCTION_RESULT = spatialdb->init_meta(FUNCTION_DB_HANDLE, db_name, FUNCTION_ERROR); FUNCTION_END_TRANSACTION(__initspatialdb); if (FUNCTION_RESULT == SQLITE_OK) { sqlite3_result_null(context); } FUNCTION_END(context); FUNCTION_FREE_TEXT_ARG(db_name); }
/* * Supports the following parameter lists: * 4: table, column, type, srid * 5: db, table, column, type, srid * 6: table, column, type, srid, z, m * 7: db, table, column, type, srid, z, m */ static void GPKG_AddGeometryColumn(sqlite3_context *context, int nbArgs, sqlite3_value **args) { spatialdb_t *spatialdb; FUNCTION_TEXT_ARG(db_name); FUNCTION_TEXT_ARG(table_name); FUNCTION_TEXT_ARG(column_name); FUNCTION_TEXT_ARG(geometry_type); FUNCTION_INT_ARG(srs_id); FUNCTION_INT_ARG(z); FUNCTION_INT_ARG(m); FUNCTION_START(context); spatialdb = (spatialdb_t *)sqlite3_user_data(context); if (nbArgs == 4) { FUNCTION_SET_TEXT_ARG(db_name, "main"); FUNCTION_GET_TEXT_ARG(context, table_name, 0); FUNCTION_GET_TEXT_ARG(context, column_name, 1); FUNCTION_GET_TEXT_ARG(context, geometry_type, 2); FUNCTION_GET_INT_ARG(srs_id, 3); FUNCTION_SET_INT_ARG(z, 2); FUNCTION_SET_INT_ARG(m, 2); } else if (nbArgs == 5) { FUNCTION_GET_TEXT_ARG(context, db_name, 0); FUNCTION_GET_TEXT_ARG(context, table_name, 1); FUNCTION_GET_TEXT_ARG(context, column_name, 2); FUNCTION_GET_TEXT_ARG(context, geometry_type, 3); FUNCTION_GET_INT_ARG(srs_id, 4); } else if (nbArgs == 6) { FUNCTION_SET_TEXT_ARG(db_name, "main"); FUNCTION_GET_TEXT_ARG(context, table_name, 0); FUNCTION_GET_TEXT_ARG(context, column_name, 1); FUNCTION_GET_TEXT_ARG(context, geometry_type, 2); FUNCTION_GET_INT_ARG(srs_id, 3); FUNCTION_GET_INT_ARG(z, 4); FUNCTION_GET_INT_ARG(m, 5); } else { FUNCTION_GET_TEXT_ARG(context, db_name, 0); FUNCTION_GET_TEXT_ARG(context, table_name, 1); FUNCTION_GET_TEXT_ARG(context, column_name, 2); FUNCTION_GET_TEXT_ARG(context, geometry_type, 3); FUNCTION_GET_INT_ARG(srs_id, 4); FUNCTION_GET_INT_ARG(z, 5); FUNCTION_GET_INT_ARG(m, 6); } FUNCTION_START_TRANSACTION(__add_geom_col); FUNCTION_RESULT = spatialdb->init_meta(FUNCTION_DB_HANDLE, db_name, FUNCTION_ERROR); if (FUNCTION_RESULT == SQLITE_OK) { FUNCTION_RESULT = spatialdb->add_geometry_column(FUNCTION_DB_HANDLE, db_name, table_name, column_name, geometry_type, srs_id, z, m, FUNCTION_ERROR); } FUNCTION_END_TRANSACTION(__add_geom_col); if (FUNCTION_RESULT == SQLITE_OK) { sqlite3_result_null(context); } FUNCTION_END(context); FUNCTION_FREE_TEXT_ARG(db_name); FUNCTION_FREE_TEXT_ARG(table_name); FUNCTION_FREE_TEXT_ARG(column_name); FUNCTION_FREE_TEXT_ARG(geometry_type); FUNCTION_FREE_INT_ARG(srid); FUNCTION_FREE_INT_ARG(z); FUNCTION_FREE_INT_ARG(m); }
status_t packagefs_close_query(fs_volume* fsVolume, void* cookie) { FUNCTION_START(); return B_OK; }