// ---------------------------------------------------------------------------- // void DMXStudio::readIniFile() { CString filename; filename.Format( "%s\\DMXStudio\\DMXStudio.ini", getUserDocumentDirectory() ); if ( m_config.read( filename ) ) { if ( m_config.m_venue_container.IsEmpty() ) m_config.m_venue_container.Format( "%s\\DMXStudio\\", getUserDocumentDirectory() ); DMXStudio::log_status( "Settings loaded from '%s'", filename ); } else DMXStudio::log( "Unable to load DMXStudio configuration file '%s'", filename ); }
// ---------------------------------------------------------------------------- // void DMXStudio::writeIniFile( ) { CString filename; filename.Format( "%s\\DMXStudio\\DMXStudio.ini.new", getUserDocumentDirectory() ); m_config.write( filename ); }
// ---------------------------------------------------------------------------- // bool SpotifyEngine::_readCredentials( CString& username, CString& credentials ) { CString filename; filename.Format( "%s\\DMXStudio\\SpotifyCredentials", getUserDocumentDirectory() ); username.Empty(); credentials.Empty(); if ( GetFileAttributes( filename ) == INVALID_FILE_ATTRIBUTES ) return false; FILE* hFile = _fsopen( filename, "rt", _SH_DENYWR ); if ( hFile == NULL ) return false; LPSTR lpUsername = username.GetBufferSetLength( 256 ); LPSTR lpCredentials = credentials.GetBufferSetLength( 2048 ); size_t read = fscanf_s( hFile, "%s %s", lpUsername, 256, lpCredentials, 256 ); username.ReleaseBuffer(); credentials.ReleaseBuffer(); fclose( hFile ); return read == 2; }
// ---------------------------------------------------------------------------- // void DMXStudio::openStudioLogFile( ) { CString filename; filename.Format( "%s\\DMXStudio\\DMXStudio.log", getUserDocumentDirectory() ); if ( PathFileExists( filename ) ) { CString move_filename; move_filename.Format( "%s\\DMXStudio\\Logs", getUserDocumentDirectory() ); CreateDirectory( move_filename, NULL ); move_filename.AppendFormat( "\\DMXStudio-%010ld.log", GetCurrentTime() ); MoveFile( filename, move_filename ); } m_hLog = _fsopen( filename, "at", _SH_DENYWR ); if ( m_hLog ) fputs( "\n", m_hLog ); }
// ---------------------------------------------------------------------------- // void SpotifyEngine::_writeCredentials( LPCSTR username, LPCSTR credentials ) { CString filename; filename.Format( "%s\\DMXStudio\\SpotifyCredentials", getUserDocumentDirectory() ); FILE* hFile = _fsopen( filename, "wt", _SH_DENYWR ); fprintf( hFile, "%s %s", username, credentials ); fclose( hFile ); }
// ---------------------------------------------------------------------------- // SpotifyEngine::SpotifyEngine(void) : m_current_track(NULL), m_track_state( TRACK_ENDED ), m_spotify_session(NULL), m_spotify_command( CMD_NONE ), m_login_state( NOT_LOGGED_IN ), m_audio_out( NULL ), m_track_length_ms( 0 ), m_track_seek_ms( 0 ), m_track_timer( this ), Threadable( "Engine" ) { memset( &spconfig, 0, sizeof(sp_session_config) ); inititializeSpotifyCallbacks(); spconfig.api_version = SPOTIFY_API_VERSION; spconfig.cache_location = "/tmp_dmxstudio_spotify"; spconfig.settings_location = spconfig.cache_location; spconfig.application_key = g_appkey; spconfig.application_key_size = g_appkey_size; spconfig.user_agent = "DMXStudio-spotify-controller"; spconfig.callbacks = &session_callbacks; spconfig.userdata = this; spconfig.compress_playlists = false; spconfig.dont_save_metadata_for_playlists = false; spconfig.initially_unload_playlists = false; spconfig.proxy = NULL; spconfig.proxy_username = NULL; spconfig.proxy_password = NULL; spconfig.tracefile = NULL; spconfig.device_id = NULL; m_trackAnalysisContainer.Format( "%s\\DMXStudio\\SpotifyTrackAnalyzeCache", getUserDocumentDirectory() ); CreateDirectory( m_trackAnalysisContainer, NULL ); }